S
Salman
When I run the below method with a 64 character string as input such
as:
sr.Encrypt("1234567890123456789012345678901234567890123456789012345678904444");
I get square boxes as my output, which means that some characters are
not being mapped in the encodings. What could be the problem?
Since my output is funny characters, my decrption will as a result
fail since it contiains invalid characters when I do a
FromBase64String.
TIA
(Code Below)
*****************************************************
public string TestEncrypt(string StrintToEncrpt)
{
string strOutput;
UTF8Encoding uTF8Encoding = new UTF8Encoding();
DESCryptoServiceProvider dESCryptoServiceProvider = new
DESCryptoServiceProvider();
dESCryptoServiceProvider.Key = uTF8Encoding.GetBytes("12345678");
dESCryptoServiceProvider.IV = dESCryptoServiceProvider.Key;
ICryptoTransform iCryptoTransform =
dESCryptoServiceProvider.CreateEncryptor();
byte[] byte1 = Convert.FromBase64String(StrintToEncrpt);
byte[] byte2 = iCryptoTransform.TransformFinalBlock(byte1, 0,
byte1.GetLength(0));
strOutput = Encoding.ASCII.GetString(byte2);
return strOutput;
}
http://www.csharpfriends.com
~Salman
as:
sr.Encrypt("1234567890123456789012345678901234567890123456789012345678904444");
I get square boxes as my output, which means that some characters are
not being mapped in the encodings. What could be the problem?
Since my output is funny characters, my decrption will as a result
fail since it contiains invalid characters when I do a
FromBase64String.
TIA
(Code Below)
*****************************************************
public string TestEncrypt(string StrintToEncrpt)
{
string strOutput;
UTF8Encoding uTF8Encoding = new UTF8Encoding();
DESCryptoServiceProvider dESCryptoServiceProvider = new
DESCryptoServiceProvider();
dESCryptoServiceProvider.Key = uTF8Encoding.GetBytes("12345678");
dESCryptoServiceProvider.IV = dESCryptoServiceProvider.Key;
ICryptoTransform iCryptoTransform =
dESCryptoServiceProvider.CreateEncryptor();
byte[] byte1 = Convert.FromBase64String(StrintToEncrpt);
byte[] byte2 = iCryptoTransform.TransformFinalBlock(byte1, 0,
byte1.GetLength(0));
strOutput = Encoding.ASCII.GetString(byte2);
return strOutput;
}
http://www.csharpfriends.com
~Salman