Created
June 6, 2019 14:55
-
-
Save alpenzoo/7e2ceb12bbc60a72136bac55714e5113 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
<?php | |
/** Encryption setup CODE **/ | |
$key = openssl_pkey_new(array('private_key_bits' => 2048)); | |
$private_key = openssl_pkey_get_details($key); | |
$public_key = $private_key['key']; | |
echo "<pre>"; | |
print_r($private_key); | |
echo "</pre>"; | |
/** Encryption CODE **/ | |
$msg = "Hi, im sending you a private message"; | |
openssl_public_encrypt($msg, $pvt_msg, $public_key); | |
echo "<pre>"; | |
print_r($msg); | |
print_r($pvt_msg); | |
echo "</pre>"; | |
/** Decryption CODE **/ | |
openssl_private_decrypt( $pvt_msg, $received_msg, $key); | |
print $received_msg; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment