navneet83/Cross-platform-AES-encryption

Encryption in c# is broken if string to encode contains non English characters (with fix)

Closed this issue · 0 comments

Code uses lenght of the input sting but is should use length of array GetBytes returns.
Fixed code should be something like that:
if (mode.Equals(EncryptMode.Encrypt))
{
//encrypt
var encbytes = _enc.GetBytes(inputText);
byte[] cypheredText = _rcipher.CreateEncryptor().TransformFinalBlock(encbytes, 0, encbytes.Length);
_out = Convert.ToBase64String(cypheredText);
}