Basically you do too many conversions between text and data. Take a look at this, for example:
string encryptValue = ConvertToHex(ASCIIEncoding.ASCII.GetString(encBuffer));
Once you get the ASCII string, why do you need to convert it to hexadecimal? This is the text! But by then you had already lost the data. If you really don't need it in hexadecimal format (in this case, follow Adam’s suggestion and change the HexToAscii method to use the byte [] instead of the string), you should just use Convert.ToBase64String:
string encryptValue = Convert.ToBase64String(encBuffer);
Use Convert.FromBase64String on the other end when decrypting. You can completely get rid of your hexagonal methods.
Oh, and generally I would not use Encoding.ASCII for starters ... I would almost always use Encoding.UTF8 . Currently, you cannot encrypt (correctly) any lines containing non-ASCII characters, such as accents.
Here is a modified version of your test program with some of these changes. Note that the names “ciphertext” and “plain text” refer to encryption ... they are still binary data, not text!
using System; using System.Security.Cryptography; using System.Text; class Program { static void Main(string[] args) { string DataForEncrypting = "this is a test"; string key = string.Empty; string iv = string.Empty; using (RijndaelManaged rmt = new RijndaelManaged()) { rmt.KeySize = 256; rmt.BlockSize = 128; rmt.Mode = CipherMode.CBC; rmt.Padding = PaddingMode.ISO10126; rmt.GenerateKey(); rmt.GenerateIV(); key = Convert.ToBase64String(rmt.Key); iv = Convert.ToBase64String(rmt.IV); } string encryptedData = _encrypt(DataForEncrypting, key, iv); string unencryptedData = _decrypt(key, iv, encryptedData); Console.WriteLine(unencryptedData); Console.WriteLine(encryptedData); Console.ReadKey(); } private static string _encrypt(string value, string key, string initVector) { using (RijndaelManaged rmt = new RijndaelManaged()) { rmt.KeySize = 256; rmt.BlockSize = 128; rmt.Mode = CipherMode.CBC; rmt.Padding = PaddingMode.ISO10126; byte[] plainText = Encoding.UTF8.GetBytes(value); byte[] cipherText = rmt.CreateEncryptor(Convert.FromBase64String(key), Convert.FromBase64String(initVector)) .TransformFinalBlock(plainText, 0, plainText.Length); return Convert.ToBase64String(cipherText); } } private static string _decrypt(string key, string initVector, string value) { using (RijndaelManaged rmt = new RijndaelManaged()) { rmt.KeySize = 256; rmt.BlockSize = 128; rmt.Mode = CipherMode.CBC; rmt.Padding = PaddingMode.ISO10126; byte[] cipherText = Convert.FromBase64String(value); byte[] plainText = rmt.CreateDecryptor(Convert.FromBase64String(key), Convert.FromBase64String(initVector)) .TransformFinalBlock(cipherText, 0, cipherText.Length); return Encoding.UTF8.GetString(plainText); } } }