Skip to content

Instantly share code, notes, and snippets.

View silikidi's full-sized avatar

SiLiKiDi silikidi

View GitHub Profile
@Radiergummi
Radiergummi / Cryptor.php
Last active June 24, 2024 19:54
A PHP class to encrypt and decrypt strings using a static application secret. Input is converted to hex strings to enable easier handling
<?php
namespace Vendor\Library;
use function bin2hex;
use function hex2bin;
use function openssl_decrypt;
use function openssl_encrypt;
use function random_bytes;
@petermuller71
petermuller71 / cryptor.php
Last active November 8, 2024 09:25
cryptor : PHP Encryption and decryption based on libsodium (standard lib >php7.2)
<?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";