Created
October 19, 2013 18:46
-
-
Save glynrob/7059838 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function public_encrypt($plaintext){ | |
$fp=fopen("./mykey.pub","r"); | |
$pub_key=fread($fp,8192); | |
fclose($fp); | |
openssl_get_publickey($pub_key); | |
openssl_public_encrypt($plaintext,$crypttext, $pub_key ); | |
return(base64_encode($crypttext)); | |
} | |
function private_decrypt($encryptedext){ | |
$fp=fopen("./mykey.pem","r"); | |
$priv_key=fread($fp,8192); | |
fclose($fp); | |
$private_key = openssl_get_privatekey($priv_key); | |
openssl_private_decrypt(base64_decode($encryptedext), $decrypted, $private_key); | |
return $decrypted; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment