Skip to content

Instantly share code, notes, and snippets.

@nazt
Created March 25, 2010 07:24
Show Gist options
  • Save nazt/343286 to your computer and use it in GitHub Desktop.
Save nazt/343286 to your computer and use it in GitHub Desktop.
<?
$message="Test Message";
//encrypt using publickey
$pubKey = openssl_pkey_get_public(file_get_contents('./keys/public'));
openssl_public_encrypt($message, $encryptedData, $pubKey);
//decrypt using privatekey
$privateKey = openssl_pkey_get_private(file_get_contents('./keys/private'));
openssl_private_decrypt($encryptedData, $decryptedData, $privateKey);
echo "Message : " . $message ."\n<br>\n";
echo "Encrypted : " . $encryptedData ."\n<br>\n";
echo "Decrypted : " . $decryptedData ."\n<br>\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment