GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Crypt::Sodium(3) User Contributed Perl Documentation Crypt::Sodium(3)

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.

box_keypair()
   Usage: my ($public_key, $secret_key) = box_keypair();
    
sign_keypair()
   Usage: my ($public_key, $secret_key) = sign_keypair();
    
crypto_sign($message, $secret_key)
   Usage: my $signed_message = crypto_sign($m, $sk);
    
crypto_sign_open($signed_message, $public_key)
   Usage: my $message = crypto_sign_open($sm, $pk);
    
crypto_box($message, $nonce, $public_key, $secret_key)
   Usage: my $ciphertext = crypto_box($m, $n, $pk, $sk);
   
   Note:  $nonce must be at least crypto_box_NONCEBYTES long.
    
crypto_box_open($ciphertext, $nonce, $public_key, $secret_key)
   Usage: my $cleartext = crypto_box_open($c, $n, $pk, $sk);
    
crypto_secretbox($message, $nonce, $key);
   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.
    
crypto_secretbox_open($ciphertext, $nonce, $key);
   Usage: my $message = crypto_secretbox($c, $n, $k);
    
crypto_hash($to_hash)
   Usage: my $hash = crypto_hash($to_hash);
    
crypto_stream($length, $nonce, $key)
   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.
    
crypto_stream_xor($message, $nonce, $key)
   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.
    
randombytes_buf($length)
   Usage: my $bytes = randombytes(24);
    
crypto_box_nonce()
   Usage: my $nonce = crypto_box_nonce();
    
crypto_stream_nonce()
   Usage: my $nonce = crypto_stream_nonce();
    
crypto_stream_key()
   Usage: my $key = crypto_stream_key();
    
crypto_pwhash_salt()
   Usage: my $salt = crypto_pwhash_salt();
    
crypto_pwhash_scrypt($password, $salt, $keylen, $opslimit, $memlimit)
   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>.
    
crypto_pwhash_scrypt_str($password, $salt, $opslimit, $memlimit)
   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.
    
crypto_scalarmult_base()
   Usage: my $pk = crypto_scalarmult_base($sk);
    
crypto_scalarmult()
   Usage: my $shared_secret = crypto_scalarmult($alice_secret, $bob_public);
    
crypto_scalarmult_safe()
   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.

2016-12-31 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.