When I run the below method with a 64 character string as input such
as:
sr.Encrypt("123 456789012345678 901234567890123 456789012345678 901234567890444 4");
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
FromBase64Strin g.
TIA
(Code Below)
*************** *************** *************** ********
public string TestEncrypt(str ing StrintToEncrpt)
{
string strOutput;
UTF8Encoding uTF8Encoding = new UTF8Encoding();
DESCryptoServic eProvider dESCryptoServic eProvider = new
DESCryptoServic eProvider();
dESCryptoServic eProvider.Key = uTF8Encoding.Ge tBytes("1234567 8");
dESCryptoServic eProvider.IV = dESCryptoServic eProvider.Key;
ICryptoTransfor m iCryptoTransfor m =
dESCryptoServic eProvider.Creat eEncryptor();
byte[] byte1 = Convert.FromBas e64String(Strin tToEncrpt);
byte[] byte2 = iCryptoTransfor m.TransformFina lBlock(byte1, 0,
byte1.GetLength (0));
strOutput = Encoding.ASCII. GetString(byte2 );
return strOutput;
}
http://www.csharpfriends.com
~Salman