I want to decrypt a string which i encrypted with c# using the StringCipher Library
what I have tried so far without success:
function decrypt($cipherText, $passPhrase)
{
$Keysize = 256;
$DerivationIterations = 1000;
$cipher_algo = "aes-256-cbc";
//$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($cipher_algo));
$cipherTextBytesWithSaltAndIv = base64_decode($cipherText);
$saltStringBytes = substr($cipherTextBytesWithSaltAndIv, 0, ($Keysize / 8));
$ivStringBytes = substr($cipherTextBytesWithSaltAndIv, ($Keysize / 8), ($Keysize / 8));
$cipherTextBytes = substr($cipherTextBytesWithSaltAndIv, (($Keysize / 8) * 2), strlen($cipherTextBytesWithSaltAndIv) - (($Keysize / 8) * 2));
$keyBytes = hash_pbkdf2("sha1", $passPhrase, $saltStringBytes, $DerivationIterations, ($Keysize / 8), true);
return openssl_decrypt($cipherTextBytes, $cipher_algo, $keyBytes, 0, $ivStringBytes);
}
The 128-bit variant in PHP: