Can't encrypt text with Turkish characters?
teytag opened this issue · comments
It does not encrypt a paragraph consisting of Turkish characters (like ş, ç, ü, ğ, ö). How can I solve this problem?
Cryptico can't encrypt many Unicode characters. If you want to encrypt foreign characters, emojis, etc. You should first encodeURI(Turkish text)
, encrypt the encoded text, decrypt, and decodeURI(encoded plaintext)
. Example:
let turkishText = "Ölçek";
turkishText = encodeURI(turkishText); // Becomes "%C3%96l%C3%A7ek"
let cipher = cryptico.encrypt(turkishText, publicKeyHere).cipher;
let plaintext = cryptico.decrypt(cipher, privateKeyHere).plaintext;
decodeURI(plaintext); // Becomes Ölçek
This can be used to encrypt any Unicode text. @wwwtyro I think it would be helpful if Cryptico automatically encoded and decoded Unicode text.
The encodeURI() function encodes special characters, except: , / ? : @ & = + $ #
So, not work your solution.
let turkish = "Türkçe karakterleri şifreliyor artık!";
result decrypt decodeURl(turkish) -> T%C3%BCrk%C3%A7e%20karakterleri%20%C5%9Fifreliyor%20art%C4%B1k!
I think you have misunderstood the response, you can encode any Unicode string with encodeURI. I have used Cryptico with encode/decodeURI in production, and it works perfectly fine. Cryptico does not have trouble encrypting / ? : @ & = + $ #
so it does not matter if encodeURI does nothing to those characters. Something must have gone wrong in your implementation, as it works fine for me:
Request to close this issue