This file contains 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 | |
namespace Vendor\Library; | |
use function bin2hex; | |
use function hex2bin; | |
use function openssl_decrypt; | |
use function openssl_encrypt; | |
use function random_bytes; |
This file contains 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 | |
print "<h1>PHP Encryption with libsodium</h1>"; | |
$message = "This text is secret"; | |
$ciphertext = cryptor::encrypt("password", $message); | |
$plaintext = cryptor::decrypt("password", $ciphertext); | |
print "Message:<br />$message <br /><br />Ciphertext:<br />$ciphertext<br /><br />Plaintext:<br />$plaintext"; |