Posted on: 11/20/2012 12:44:35 AM | Views : 526

Hi Friends,
I have written a code for encryption and decryption. Its throwing error "invalid length for a base-64 char array while decrypting the string". My code is below. Please help me to solve this issue.
private byte[] key = { }; private byte[] IV = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef }; private string sEncryptionKey = "r0b1nr0y"; public string Decrypt(string stringToDecrypt) { byte[] inputByteArray = new byte[stringToDecrypt.Length]; try { key = System.Text.Encoding.UTF8.GetBytes(sEncryptionKey); DESCryptoServiceProvider des = new DESCryptoServiceProvider(); inputByteArray = Convert.FromBase64String(stringToDecrypt.Replace(" ","+")); MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms,des.CreateDecryptor(key, IV), CryptoStreamMode.Write); ...

Go to the complete details ...