开发者

TripleDES Decryption in C#

开发者 https://www.devze.com 2023-03-09 03:35 出处:网络
TripleDES = new TripleDESCryptoServiceProvider(); this.GenerateKey(); //Generate Key .. TripleDES.Mode = CipherMode.CBC;
TripleDES = new TripleDESCryptoServiceProvider();
this.GenerateKey(); //Generate Key ..
TripleDES.Mode = CipherMode.CBC;
TripleDES.Padding = 开发者_JS百科PaddingMode.PKCS7;



byte[] cipher = new byte[0];
ICryptoTransform ict = TripleDES.CreateEncryptor();
cipher = ict.TransformFinalBlock(data, 0, data.Length); 

Hi when i decypt the message using the same instance of the TripleDES = new TripleDESCryptoServiceProvider(); works properly but when i try to dcrypt using a new instance it says "Bad Data"


I believe you are generating a new key on each run. Try giving a static key instead of using this.GenerateKey();.

0

精彩评论

暂无评论...
验证码 换一张
取 消