Ниже приведены соответствующие блоки кода, используемые для генерации ключа и IV в C# и PHP.< /p>
Фрагмент кода C#
Код: Выделить всё
string password = 'pass here';
byte[] salt = new byte[] { 0x43, 0x87, 0x23, 0x72, 0x45, 0x56, 0x68, 0x14, 0x62, 0x84 };
PasswordDeriveBytes pdb = new PasswordDeriveBytes(password, salt);
aesAlg.Key = pdb.GetBytes(32);
aesAlg.IV = pdb.GetBytes(16);
Console.WriteLine("Key: " + BitConverter.ToString(aesAlg.Key).Replace("-", ""));
Console.WriteLine("IV: " + BitConverter.ToString(aesAlg.IV).Replace("-", ""));
Код: Выделить всё
$password = 'pass here';
$salt = hex2bin('43872372455668146284');
$keyLength = 32; // 32 bytes for AES-256 key
$ivLength = 16; // 16 bytes for AES block size
$combinedLength = $keyLength + $ivLength;
$derivedBytes = hash_pbkdf2("sha1", $password, $salt, 100, $combinedLength, true);
$key = substr($derivedBytes, 0, $keyLength);
$iv = substr($derivedBytes, $keyLength, $ivLength);
echo "Key: " . bin2hex($key) . "\n";
echo "IV: " . bin2hex($iv) . "\n";
Подробнее здесь: https://stackoverflow.com/questions/786 ... tor-in-php