navneet83 / Cross-platform-AES-encryption

Basic cross platform AES encryption
Apache License 2.0
320 stars 152 forks source link

Corrupted decrypted string with emojis #44

Open AlbertMontserrat opened 8 years ago

AlbertMontserrat commented 8 years ago

I'm not able to encrypt a text with emojis in the server, and decrypt it in iOS. Have you tested it? Is there a way to do it?

Thanks

AlbertMontserrat commented 8 years ago

I acheived it with this code:

 if (isEncrypt) {
        encryptor = _crypto2['default'].createCipheriv(this._algorithm, keyBl.toString(), ivBl.toString());
        //encryptor.setEncoding(this._encoding);
        //encryptor.write(text);
        //encryptor.end();
        //return encryptor.read();
        var encrypted = encryptor.update(text, this._charset, this._encoding);
        encrypted += encryptor.final(this._encoding);
 }
ybanezmarjune commented 8 years ago

Hi @AlbertMontserrat

I have problem same as yours. I already send a pull request to the author. But it seems they are busy to help us. If you want, just fix it by your self.

This problem is in c# (Back-end) you must modify it. This problem occurs when you try to encrypt a symbol text.

The only way to fix this error is to modify your back-end(c#) and get the converted UTF-18 encoding length from your StringToConvert.

Refer the link below and try it by yourself.

https://github.com/Pakhee/Cross-platform-AES-encryption/pull/45/files