keys = GenerateAsymmetricKeyPair[];
message = Rasterize[Graphics[Disk[]], RasterSize -> 10];
Encrypt[keys["PrivateKey"], message]

generates the error

Encrypt::len: Input too long for this encryption method.

despite the message having a ByteCount of only 4144. Is this some kind of error, or is there a reason why non-tiny messages are infeasible? (11.1.0, OS X)

  • $\begingroup$ You could try other short messages, to see if the problem is really the length or actually some other feature of what you are trying to encrypt $\endgroup$
    – mikado
    Jun 18, 2017 at 16:34

1 Answer 1


When using GenerateAsymmetricKeyPair the key size must be longer than the message. So the following works.

keys = GenerateAsymmetricKeyPair[Method -> <|"KeySize" -> 5000|>];
message = Rasterize[Graphics[Disk[]], RasterSize -> 10]
Encrypt[keys["PrivateKey"], message]


The default for "KeySize" is 4096 which is a bit too small for your raster of 4144 bytes.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.