Skip to content
/ crypto Public

The Nuxed Crypto component provides a high-level cryptography interface that relies on libsodium for all of its underlying cryptography operations.

License

Notifications You must be signed in to change notification settings

nuxed/crypto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

6ee5f0f · Nov 21, 2020

History

62 Commits
Nov 21, 2020
Nov 9, 2019
Nov 15, 2020
Nov 15, 2020
Nov 15, 2020
Nov 15, 2020
Oct 20, 2019
Nov 15, 2020
Nov 2, 2019
Nov 20, 2020
Nov 20, 2020
Oct 23, 2019
Oct 24, 2019

Repository files navigation

Coding standards status Static analysis status Unit tests status Total Downloads Latest Stable Version License

Nuxed Crypto

The Nuxed Crypto component provides a high-level cryptography interface that relies on libsodium for all of its underlying cryptography operations.

inspired by Halite.

Important

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 favourite trusted hackers to hammer it for implementation errors and bugs before even thinking about deploying it in production.

Installation

This package can be installed with Composer.

$ composer require nuxed/crypto

Example

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!
}

Security

For information on reporting security vulnerabilities in Nuxed, see SECURITY.md.


License

Nuxed is open-sourced software licensed under the MIT-licensed.