下面的代码将成功生成 KEY 进行加密。如何使用相同的盐和密码在 PHP 中重新创建它以生成密钥以解密消息?
public static string GenerateKey(string passkey)
{
var myAlg = new RijndaelManaged()
{
Padding = PaddingMode.PKCS7,
Mode = CipherMode.CBC,
KeySize = 256,
BlockSize = 256,
};
byte[] salt = Encoding.ASCII.GetBytes("Some salt value");
Rfc2898DeriveBytes keys = new Rfc2898DeriveBytes(passkey, salt);
myAlg.Key = keys.GetBytes(myAlg.KeySize / 8);
return (Encoding.ASCII.GetString(myAlg.Key));
}