Hi
I have a couple of encryption methods but when I call decrypt I get the
string back but with a load \0 escape characters on the end?
Any idea why? It is actually causing problems in some places, here are my
methods:
public static string Encrypt(string input, byte[] key, byte[] iv)
{
byte[] inputStringByte s = Encoding.ASCII. GetBytes(input) ;
byte[] outputBytes;
MemoryStream ms = new MemoryStream(in putStringBytes. Length);
RijndaelManaged rijndael = new RijndaelManaged ();
ICryptoTransfor m rdTransform = rijndael.Create Encryptor((byte[])key.Clone(),
(byte[])iv.Clone());
CryptoStream cs = new CryptoStream(ms , rdTransform, CryptoStreamMod e.Write);
cs.Write(inputS tringBytes, 0, inputStringByte s.Length);
cs.FlushFinalBl ock();
outputBytes = ms.ToArray();
ms.Close();
cs.Close();
rdTransform.Dis pose();
rijndael.Clear( );
return Convert.ToBase6 4String(outputB ytes);
}
public static string Decrypt(string input, byte[] key, byte[] iv)
{
byte[] inputStringByte s = Convert.FromBas e64String(input );
byte[] outputTextBytes = new byte[inputStringByte s.Length];
RijndaelManaged rijndael = new RijndaelManaged ();
MemoryStream ms = new MemoryStream(in putStringBytes) ;
ICryptoTransfor m rdTransform = rijndael.Create Decryptor((byte[])key.Clone(),
(byte[])iv.Clone());
CryptoStream cs = new CryptoStream(ms , rdTransform, CryptoStreamMod e.Read);
cs.Read(outputT extBytes, 0, outputTextBytes .Length);
ms.Close();
cs.Close();
rdTransform.Dis pose();
rijndael.Clear( );
return Encoding.ASCII. GetString(outpu tTextBytes);
}
Thanks
Kev