I am implementing my own AES code and I am encountering some problems during the decryption.
byte[] output;
output = Encrypt(EncryptBufferInput);//encrypt "12",output[] is 300532188151293E4ACA3BA529B821C1
str.Append(Encoding.ASCII.GetString(output) );
output = Decrypt(DecryptBufferInput);//in hex, DecryptBufferInput should be "300532188151293E4ACA3BA529B821C1"
str.Append(Encoding.ASCII.GetString(output));//does not decrypt back to "12"
So, if I try to encrypt "12", it gives me a value of "300532188151293E4ACA3BA529B821C1" in hex form. when I try to decrypt it back to "12", it gives me a wrong value because the DecryptBufferInput is not "300532188151293E4ACA3BA529B821C1" but some other value...Only the first few values are same. EncryptBufferInput and DecryptBufferInput are both byte[] arrays, and I use Encoding.ASCII.GetBytes(string) to fill the byte array with the corresponding string(string to encrypt or string to decrypt). What am I doing wrong??