0

I have a simple web application that requires sign-up and, I want to encrypt/decrypt the password using the openssl_encrypt and openssl_decrypt function. I am new to PHP and have no idea how to import the functions or install the library into my project.

Ideally I want to do something like this.

 $string_to_encrypt="password";
 $key="key";
 $encrypted_string=openssl_encrypt($string_to_encrypt,"AES-128-ECB",$password);
 $decrypted_string=openssl_decrypt($encrypted_string,"AES-128-ECB",$password);
jon givony
  • 197
  • 2
  • 3
  • 9
  • 1
    Uncomment the line `;extension=php_openssl.so` (remove the leading semicolon) in `php.ini` – helllomatt Dec 10 '17 at 16:51
  • @helllomatt do I have to include any requires or includes in my php script, or can I just directly call the function? – jon givony Dec 10 '17 at 17:22
  • No, you don't need to import anything. After you uncomment it, restart php/apache and it will load in automatically. – helllomatt Dec 10 '17 at 18:43
  • That's not necessary: A HASH will do. look up `password_hash()` and `password_verify()` in the php manual – RiggsFolly Dec 10 '17 at 19:13
  • Possible duplicate of [Fatal error: Call to undefined function openssl\_random\_pseudo\_bytes()](https://stackoverflow.com/questions/11212808/fatal-error-call-to-undefined-function-openssl-random-pseudo-bytes) – Jo. Jan 16 '18 at 19:23

0 Answers0