param (
[string]$InputFile,
[string]$OutputFile,
[string]$Password
)
$Base64Data = Get-Content $InputFile -Raw
$EncryptedBytes = [System.Convert]::FromBase64String($Base64Data)
$Salt = $EncryptedBytes[0..15]
$IV = $EncryptedBytes[16..31]
$CipherText = $EncryptedBytes[32..($EncryptedBytes.Length-1)]
$Rfc2898 = New-Object System.Security.Cryptography.Rfc2898DeriveBytes($Password, $Salt, 10000)
$Key = $Rfc2898.GetBytes(32)
$Aes = [System.Security.Cryptography.Aes]::Create()
$Aes.KeySize = 256
$Aes.BlockSize = 128
$Aes.Mode = [System.Security.Cryptography.CipherMode]::CBC
$Aes.Padding = [System.Security.Cryptography.PaddingMode]::PKCS7
$Aes.Key = $Key
$Aes.IV = $IV
$Decryptor = $Aes.CreateDecryptor()
$DecryptedBytes = $Decryptor.TransformFinalBlock($CipherText, 0, $CipherText.Length)
$Aes.Dispose()
[System.IO.File]::WriteAllBytes($OutputFile, $DecryptedBytes)
Write-Host "Visszafejtés befejezve: $OutputFile"