Hello Tai:
Encryption:
TripleDES des3 = new TripleDESCryptoServiceProvider();
byte[] buff = ASCIIEncoding.ASCII.GetBytes(source.Text);
byte[] bytesKey = ASCIIEncoding.ASCII.GetBytes(encKey.Text);
des3.Mode = CipherMode.ECB;
if (encKey.Text.Length != 24)
{
outputStr = "Key size is illegal. Please supply a 192bit key (24
characters)";
}
else
{
des3.Key = bytesKey;
byte[] encrypted = des3.CreateEncryptor().TransformFinalBlock(buff, 0,
buff.Length);
outputStr = Convert.ToBase64String(encrypted);
}
Decryption:
TripleDES des3_dec = new TripleDESCryptoServiceProvider();
byte[] buff = ASCIIEncoding.ASCII.GetBytes(source.Text);
byte[] bytesKey = ASCIIEncoding.ASCII.GetBytes(encKey.Text); // Note that
the key is 192bit long
des3_dec.Mode = CipherMode.ECB;
.....
outputStr =
Convert.FromBase64String(des3_dec.CreateDecryptor( ).TransformFinalBlock(buff
, 0, buff.Length));
I gleaned this from a couple of other postings on the
microsoft.public.dotnet.security newsgroup.
I'm no expert on crypto, but some of the folks on that NG certainly are, and
may be able to help you further if this code isn't sufficient.
Hope this helps,
--- Nick
"Tai Kelvin" <ke*******@gmail.com> wrote in message
news:e8**************@TK2MSFTNGP11.phx.gbl...
Hi Nick,
Do you have sample or tutorial how to decrypt 3DES/DES using traditional
asp or C#/ASPX ?
Please advise.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!