php aes‐256‐cbc,与PHP一样,以C#解密用AES-256-CBC加密的数据

博客作者在尝试使用C# 2013解密之前用PHP AES-256-CBC加密的数据时遇到了问题。C#代码在设置Key时抛出错误,指出指定的密钥大小不适用于该算法。讨论中提到AES-256-CBC的块大小应该是128位,而非256位。
摘要由CSDN通过智能技术生成

I did some encryption using PHP in my Database and would normally decrypt using:

$encrypt_method = "AES-256-CBC";

$secret_key = "testing";

$secret_iv = "testingyes!!!";

$key = hash('sha256', $secret_key); // hash the key

$iv = substr(hash('sha256', $secret_iv), 0, 16); // iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning

echo(openssl_decrypt(base64_decode($data), $encrypt_method, $key, 0, $iv)); // the decrypted data

I'm trying to do the same task but with C# 2013 to decrypt the same data, any ideas?

I would encrypt in php using:

$encrypt_method = "AES-256-CBC";

$secret_key = "testing";

$secret_iv = "testingyes!!!";

$key = hash('sha256', $secret_key); // hash the key

$iv = substr(hash('sha2

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值