wwwtyro / cryptico

An easy-to-use encryption system utilizing RSA and AES for javascript.
http://wwwtyro.github.com/cryptico
1.18k stars 347 forks source link

Getting error "Message too long for RSA (n=32, l=32)" #37

Open tcoupe opened 5 years ago

tcoupe commented 5 years ago

I'm getting this error in RSAEncrypt when trying to do AES-CBC 256 bit encryption. I think it has to do with the age of the JavaScript engine and use of String.fromCharCode() as it relates to UTF-8 encoding, but I'm not sure. Any ideas what's wrong? my code is: var Bits = 256; RSAkey = cryptico.generateRSAKey(PassWord, Bits); // PassWord is "12340000000..." 32 characters long PublicKeyString = cryptico.publicKeyString(RSAkey); var ret = cryptico.encrypt(ping, PublicKeyString); // fails in here, ping is a JSON (string)

matheograil commented 4 years ago

According to the documentation :

bitlength: integer, length of the RSA key (512, 1024, 2048, 4096, 8192).

So 256 is a wrong value.