wwwtyro / cryptico

An easy-to-use encryption system utilizing RSA and AES for javascript.

Home Page:http://wwwtyro.github.com/cryptico

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

tcoupe opened this issue · comments

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)

According to the documentation :

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

So 256 is a wrong value.