Crypt::Sodium - Perl bindings for libsodium (NaCL) https://github.com/jedisct1/libsodium
use Crypt::Sodium; my $k = crypto_stream_key(); my $n = crypto_stream_nonce(); my $ciphertext = crypto_stream_xor("Hello World!", $n, $k); my $cleartext = crypto_stream_xor($ciphertext, $n, $k);
Simple wrapper around NaCL functions as provided by libsodium. crypto_box, crypto_stream, crypto_hash, and crypto_sign are all present and accounted for. None of the specific implementations are exposed, only the default implementations are.
Usage: my ($public_key, $secret_key) = box_keypair();
Usage: my ($public_key, $secret_key) = sign_keypair();
Usage: my $signed_message = crypto_sign($m, $sk);
Usage: my $message = crypto_sign_open($sm, $pk);
Usage: my $ciphertext = crypto_box($m, $n, $pk, $sk); Note: $nonce must be at least crypto_box_NONCEBYTES long.
Usage: my $cleartext = crypto_box_open($c, $n, $pk, $sk);
Usage: my $ciphertext = crypto_secretbox($m, $n, $k); Note: $nonce must be at least crypto_box_NONCEBYTES long, $key must be at least crypto_box_SECRETKEYBYTES long.
Usage: my $message = crypto_secretbox($c, $n, $k);
Usage: my $hash = crypto_hash($to_hash);
Usage: my $stream = crypto_stream($length, $nonce, $key); Note: $nonce must be at least crypto_stream_NONCEBYTES long, $key must be at least crypto_stream_KEYBYTES long.
Usage: my $ciphertext = crypto_stream_xor($message, $nonce, $key); my $cleartext = crypto_stream_xor($ciphertext, $nonce, $key); Note: $nonce must be at least crypto_stream_NONCEBYTES long, $key must be at least crypto_stream_KEYBYTES long.
Usage: my $bytes = randombytes(24);
Usage: my $nonce = crypto_box_nonce();
Usage: my $nonce = crypto_stream_nonce();
Usage: my $key = crypto_stream_key();
Usage: my $salt = crypto_pwhash_salt();
Usage: my $derivedkey = crypto_pwhash_scrypt($password, $salt, $keylen, $opslimit, $memlimit); Note: $salt must be crypto_pwhash_SALTBYTES long, use crypto_pwhash_salt() to generate $keylen maybe omitted, the default is crypto_box_SEEDBYTES $opslimit maybe omitted, the default is crypto_pwhash_OPSLIMIT $memlimit maybe omitted, the default is crypto_pwhash_MEMLIMIT See L<http://doc.libsodium.org/password_hashing/README.html> for details>.
Usage: my $hash_string = crypto_pwhash_scrypt_str($password, $salt); Note: like the crypto_pwhash_scrypt function, this function can also take an opslimit and memlimit value. The default opslimit is exported into your namespace as crypto_pwhash_OPSLIMIT and the default memlimit is exported as crypto_pwhash_MEMLIMIT, if you have a really important password to hash and don't mind using 1GB of ram and 10s+ of CPU time on an i7-class CPU, you can use crypto_pwhash_OPSLIMIT_SENSITIVE and crypto_pwhash_MEMLIMIT_SENSITIVE instead.
Usage: my $pk = crypto_scalarmult_base($sk);
Usage: my $shared_secret = crypto_scalarmult($alice_secret, $bob_public);
Usage: my $shared_secret = crypto_scalarmult_safe($alice_secret, $bob_public, $alice_public); Note: The shared secret generated is a hash of the output of crypto_scalarmult xor'd with the two public keys as outlined here L<https://download.libsodium.org/doc/advanced/scalar_multiplication.html>.
crypto_stream_KEYBYTES crypto_stream_NONCEBYTES crypto_box_NONCEBYTES crypto_box_PUBLICKEYBYTES crypto_box_SECRETKEYBYTES crypto_box_MACBYTES crypto_box_SEEDBYTES crypto_secretbox_MACBYTES crypto_secretbox_KEYBYTES crypto_secretbox_NONCEBYTES crypto_sign_PUBLICKEYBYTES crypto_sign_SECRETKEYBYTES crypto_pwhash_SALTBYTES crypto_pwhash_OPSLIMIT crypto_pwhash_MEMLIMIT crypto_pwhash_STRBYTES
https://github.com/jedisct1/libsodium http://nacl.cr.yp.to/
libsodium 1.0.0 or higher
Michael Gregorowicz, <mike@mg2.org>
Copyright (C) 2015 Michael Gregorowicz
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.18 or, at your option, any later version of Perl 5 you may have available.
To install Crypt::Sodium, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Crypt::Sodium
CPAN shell
perl -MCPAN -e shell install Crypt::Sodium
For more information on module installation, please visit the detailed CPAN module installation guide.