Asymmetric Encryption in PHP
Data encryption and decryption using public and private key by openssl.
Firstly, need to install openssl in your device. For check openssl go to Terminal or PowerShell and type
openssl
If you have openssl then
mkdir keys cd keys openssl genrsa -des3 -out private.pem 4096
4096 is actually byte of private key. if you want to change this value, you can change it.
Need to write a pass phrase. Pass phrase must be at-least 2 character.
openssl rsa -in private.pem -out public.pem -outform PEM -pubout
Again write a same pass phrase
Finally Run this code.
Comments
Leave a comment
You are not LoggedIn but you can comment as an anonymous user which requires manual approval. For better experience please Login.