PHP code example of nuxed / crypto
1. Go to this page and download the library: Download nuxed/crypto library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nuxed / crypto example snippets
hack
use namespace Nuxed\{Crypto, Filesystem};
use namespace Nuxed\Crypto\Symmetric;
<<__EntryPoint>>
async function main(): Awaitable<void> {
// generate a key :
$key = Symmetric\Encryption\Key::generate();
// or load a stored encryption key :
$file = new Filesystem\File('/path/to/encryption.key');
$key = $key = Symmetric\Encryption\Key::import(
new Crypto\HiddenString(await $file->read())
);
$message = new Crypto\HiddenString('Hello, World!');
$ciphertext = Symmetric\Encryption\encrypt($message, $key);
$plaintext = Symmetric\Encryption\decrypt($ciphertext, $key);
print $plaintext->toString(); // Hello, World!
}