Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

TipleDes decyption - the length of the data to decrypt is invalid

$
0
0

Hello everyone,

I need some help with this method which is rising the error while trying to decrypt.

public const string key = "secretkey";

public static string TripleDESDecrypt(string cipherString)
{
byte[] keyArray;
byte[] toDecryptArray = Convert.FromBase64String(cipherString);

MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
hashmd5.Clear();

TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
tdes.Key = keyArray;
tdes.Mode = CipherMode.ECB;
tdes.Padding = PaddingMode.PKCS7;

ICryptoTransform cTransform = tdes.CreateDecryptor();
byte[] resultArray = cTransform.TransformFinalBlock(toDecryptArray, 0, toDecryptArray.Length);
tdes.Clear();

return UTF8Encoding.UTF8.GetString(resultArray);
}

Any help? Thanks


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>