Nuxed Crypto a high-level cryptography interface that relies on libsodium for all of its underlying cryptography operations, inspired by Halite
.
Although this library has developed with care, it has not been examined by security experts, there will always be a chance that we overlooked something. Please ask your favorite trusted hackers to hammer it for implementation errors and bugs before even thinking about deploying it in production.
This package can be installed with Composer.
$ composer require nuxed/crypto
Documentation for Nuxed Crypto can be found in this repository under the docs folder.
use namespace Nuxed\Crypto;
use namespace Nuxed\Crypto\Symmetric;
use namespace HH\Lib\Experimental\File;
<<__EntryPoint>>
async function main(): void {
// generate a key :
$key = Symmetric\Encryption\Key::generate();
// or load a stored encryption key :
await using ($file = File\open_read_only('/path/to/encryption.key')) {
$key = Symmetric\Encryption\Key::import(
new Crypto\HiddenString(
await $file->readAsync()
)
);
}
$message = new Crypto\HiddenString('Hello, World!');
$ciphertext = Symmetric\Encryption\encrypt($message, $key);
$plaintext = Symmetric\Encryption\decrypt($ciphertext, $key);
print $plaintext->toString(); // Hello, World!
}
For information on reporting security vulnerabilities in Nuxed Crypto, see SECURITY.md.
The Nuxed Crypto library is open-sourced software licensed under the MIT-licensed.