4
$\begingroup$

This

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)

$\endgroup$
1
  • $\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 '17 at 16:34
5
$\begingroup$

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]

encrypted

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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