-
May 9th, 2005, 08:00 AM
#1
Triple DES Encryption
Following code decrypts the encrypted string "thisDecode" but gives an error:
(Unhandled Exception: System.Security.Cryptography.CryptographicException: Bad Data.
at System.Security.Cryptography.CryptoAPITransform._DecryptData(IntPtr hKey,
Byte[] rgb, Int32 ib, Int32 cb, Boolean fDone)
at System.Security.Cryptography.CryptoAPITransform.TransformFinalBlock(Byte[]
inputBuffer, Int32 inputOffset, Int32 inputCount))
Code:
TripleDESCryptoServiceProvider* des;
des = new TripleDESCryptoServiceProvider();
des->GenerateKey();
des->GenerateIV();
ICryptoTransform *Decryptor;
Decryptor = des ->CreateDecryptor();
ASCIIEncoding* ascii2 = new ASCIIEncoding();
Byte DCode[] = Convert::FromBase64String(thisDecode);
String* decrypted;
decrypted = ascii2->ASCII->GetString(Decryptor->TransformFinalBlock(DCode, 0, DCode->Length),0,DCode->Length);
return decrypted;
Help needed regarding this.
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|