I wrote a simple encryption / decryption program, when I decrypted the encrypted text it shows grabridge value end of the decrypted text. my c# code and out put of the code are given below. please help me to get the original text after the decrypt without grabage
public class CrypterText { static byte[] chiperbytes; static byte[] plainbytes; static byte[] plainKey; static SymmetricAlgorithm desObj; public static string encryptData(string ciperData) { desObj = Rijndael.Create(); plainbytes = Encoding.ASCII.GetBytes(ciperData); plainKey = Encoding.ASCII.GetBytes("0123456789abcdef"); desObj.Key = plainKey; desObj.Mode = CipherMode.CBC; desObj.Padding = PaddingMode.ISO10126; System.IO.MemoryStream ms = new System.IO.MemoryStream(); CryptoStream cs = new CryptoStream(ms, desObj.CreateEncryptor(), CryptoStreamMode.Write); cs.Write(plainbytes, 0, plainbytes.Length); cs.Close(); chiperbytes = ms.ToArray(); ms.Close(); return Encoding.ASCII.GetString(chiperbytes); } public static string decrypt() { MemoryStream ms = new MemoryStream(chiperbytes); CryptoStream cs = new CryptoStream(ms, desObj.CreateDecryptor(), CryptoStreamMode.Read); cs.Read(chiperbytes, 0, chiperbytes.Length); plainbytes = ms.ToArray(); cs.Close(); ms.Close(); return Encoding.ASCII.GetString(plainbytes); } }
