Answer the question
In order to leave comments, you need to log in
What is the purpose of RSA?
Tell me, what is the essence of RSA encryption? I can not understand. Here take AES. If AES is added to the database encrypted, and if there is a key, it is displayed decrypted ( for example, if an attacker got into the database, he will not decrypt without a key, the essence is clear ), but what is the point of RSA? I tried in the same way, either one character is added to the base, or there is a void in general. But if you output as in the example below, then everything works fine.
Here is an example of encryption and decryption on the same page:
<?php
$rsa = new Crypt_RSA();
$rsa->loadKey('...'); // публичный ключ
$plaintext = 'machmala'; // текст
$ciphertext = $rsa->encrypt($plaintext); // шифруем текст
echo $ciphertext, '<hr>'; // выводим шифрованный текст
$rsa->loadKey('...'); // если видим приватный ключ, то расшифровываем
echo $rsa->decrypt($ciphertext); // расшифровка
?>
Answer the question
In order to leave comments, you need to log in
Do not confuse symmetric and asymmetric encryption.
AES - you take the password and encrypt the data with it.
RSA - you take the public key, encrypt the data with it, and you can only decrypt it with the second half (private key).
AES and RSA have different goals and different applications.
> What is the essence of RSA encryption?
1. Encryption of small data of a strictly defined length.
2. Signature
3. Key exchange.
Usually it is used like this - Encrypt AES keys to securely transfer them to the Other party and then use AES - which is much faster.
Perhaps you are trying to encrypt a block of data that is not compatible with RSA. and so it throws an error.
at the beginning, you need to ask $rsa how long the data should be for encryption.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question