T
T
tuxx2019-04-01 18:50:53
PHP
tuxx, 2019-04-01 18:50:53

Data size to encrypt via openssl?

To encrypt data using php, I took openssl via openssl_public_encrypt\openssl_private_decrypt. Generated keys:

openssl genrsa -des3 -out private_rsa.pem 2048
openssl rsa -in private_rsa.pem -outform PEM -pubout -out public_rsa.pem

At one point, I encountered the fact that lines longer than 255 characters began to give an error:
error:0406D06E:rsa routines:RSA_padding_add_PKCS1_type_2:data too large for key size large data

I made it so that strings longer than 255 characters are divided into pieces and each piece is encrypted separately, but sometimes the decryption fails correctly.
Sample code for the current version of the encryption\decryption class on ideone

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shamanov, 2019-04-01
@SilenceOfWinter

this is your key greater than 255, not encrypted data - hash the key

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question