Functions

add(string $left, string $right)

Add the right operand to the left

string
bin2hex(string $binary)

Convert to hex without side-chanels

int
compare(string $left, string $right)

Compare two strings in constant time

string
crypto_aead_aes256gcm_decrypt(string $msg, string $nonce, string $key, string $ad = '')

Authenticated Encryption with Associated Data (decrypt) AES-256-GCM

string
crypto_aead_aes256gcm_encrypt(string $msg, string $nonce, string $key, string $ad = '')

Authenticated Encryption with Associated Data (encrypt) AES-256-GCM

bool
crypto_aead_aes256gcm_is_available()

Can you access AES-256-GCM? This is only available if you have supported hardware.

string
crypto_aead_chacha20poly1305_decrypt(string $msg, string $nonce, string $key, string $ad = '')

Authenticated Encryption with Associated Data (decrypt) ChaCha20 + Poly1305

string
crypto_aead_chacha20poly1305_encrypt(string $msg, string $nonce, string $key, string $ad = '')

Authenticated Encryption with Associated Data (encrypt) ChaCha20 + Poly1305

string
crypto_auth(string $msg, string $key)

Secret-key message authentication HMAC SHA-512/256

bool
crypto_auth_verify(string $mac, string $msg, string $key)

Secret-key message verification HMAC SHA-512/256

string
crypto_box(string $msg, string $nonce, string $keypair)

Public-key authenticated encryption (encrypt) X25519 + Xsalsa20 + Poly1305

string
crypto_box_keypair()

Generate an X25519 keypair for use with the crypto_box API

string
crypto_box_keypair_from_secretkey_and_publickey(string $secretkey, string $publickey)

Create an X25519 keypair from an X25519 secret key and X25519 public key

string
crypto_box_open(string $msg, string $nonce, string $keypair)

Public-key authenticated encryption (decrypt) X25519 + Xsalsa20 + Poly1305

string
crypto_box_publickey(string $keypair)

Get an X25519 public key from an X25519 keypair

string
crypto_box_publickey_from_secretkey(string $secretkey)

Derive an X25519 public key from an X25519 secret key

string
crypto_box_seal(string $message, string $publickey)

Anonymous public-key encryption (encrypt) X25519 + Xsalsa20 + Poly1305 + BLAKE2b

string
crypto_box_seal_open(string $encrypted, string $keypair)

Anonymous public-key encryption (decrypt) X25519 + Xsalsa20 + Poly1305 + BLAKE2b

string
crypto_box_secretkey(string $keypair)

Extract the X25519 secret key from an X25519 keypair

string
crypto_box_seed_keypair(string $seed)

Derive an X25519 keypair for use with the crypto_box API from a seed

string
crypto_generichash(string $input, string $key = '', int $length = 32)

Fast and secure cryptographic hash

string
crypto_generichash_final(string $state, int $length = 32)

Get the final hash BLAKE2b

string
crypto_generichash_init(string $key = '', int $length = 32)

Create a new hash state (e.g. to use for streams) BLAKE2b

bool
crypto_generichash_update(string $hashState, string $append)

Update the hash state with some data BLAKE2b

string
crypto_kx(string $secretkey, string $publickey, string $client_publickey, string $server_publickey)

Elliptic Curve Diffie Hellman Key Exchange X25519

string
crypto_pwhash(int $out_len, string $passwd, string $salt, int $opslimit, int $memlimit)

Secure password-based key derivation function Argon2i

string
crypto_pwhash_scryptsalsa208sha256(int $out_len, string $passwd, string $salt, int $opslimit, int $memlimit)

Secure password-based key derivation function Scrypt

string
crypto_pwhash_scryptsalsa208sha256_str(string $passwd, int $opslimit, int $memlimit)

Get a formatted password hash (for storage) Scrypt

bool
crypto_pwhash_scryptsalsa208sha256_str_verify(string $hash, string $passwd)

Verify a password against a hash Scrypt

string
crypto_pwhash_str(string $passwd, int $opslimit, int $memlimit)

Get a formatted password hash (for storage) Argon2i

bool
crypto_pwhash_str_verify(string $hash, string $passwd)

Verify a password against a hash Argon2i

string
crypto_scalarmult(string $ecdhA, string $ecdhB)

Elliptic Curve Diffie Hellman over Curve25519 X25519

string
crypto_scalarmult_base(string $sk)

Scalar multiplication of the base point and your key

string
crypto_secretbox(string $plaintext, string $nonce, string $key)

Authenticated secret-key encryption (encrypt) Xsals20 + Poly1305

string
crypto_secretbox_open(string $ciphertext, string $nonce, string $key)

Authenticated secret-key encryption (decrypt) Xsals20 + Poly1305

string
crypto_shorthash(string $message, string $key)

A short keyed hash suitable for data structures SipHash-2-4

string
crypto_sign(string $message, string $secretkey)

Digital Signature Ed25519

string
crypto_sign_detached(string $message, string $secretkey)

Digital Signature (detached) Ed25519

string
crypto_sign_ed25519_pk_to_curve25519(string $sign_pk)

Convert an Ed25519 public key to an X25519 public key

string
crypto_sign_ed25519_sk_to_curve25519(string $sign_sk)

Convert an Ed25519 secret key to an X25519 secret key

string
crypto_sign_keypair()

Generate an Ed25519 keypair for use with the crypto_sign API

string
crypto_sign_keypair_from_secretkey_and_publickey(string $secretkey, string $publickey)

Create an Ed25519 keypair from an Ed25519 secret key + Ed25519 public key

string
crypto_sign_open(string $signed_message, string $publickey)

Verify a signed message and return the plaintext

string
crypto_sign_publickey(string $keypair)

Get the public key from an Ed25519 keypair

string
crypto_sign_publickey_from_secretkey(string $secretkey)

Derive an Ed25519 public key from an Ed25519 secret key

string
crypto_sign_secretkey(string $keypair)

Get the secret key from an Ed25519 keypair

string
crypto_sign_seed_keypair(string $seed)

Derive an Ed25519 keypair for use with the crypto_sign API from a seed

bool
crypto_sign_verify_detached(string $signature, string $msg, string $publickey)

Verify a detached signature

string
crypto_stream(int $length, string $nonce, string $key)

Create a keystream from a key and nonce Xsalsa20

string
crypto_stream_xor(string $plaintext, string $nonce, string $key)

Encrypt a message using a stream cipher Xsalsa20

string
hex2bin(string $hex)

Convert from hex without side-chanels

string
increment(string $nonce)

Increment a string in little-endian

int
library_version_major()

Get the true major version of libsodium

int
library_version_minor()

Get the true minor version of libsodium

int
memcmp(string $left, string $right)

Compare two strings in constant time

memzero(string $target)

Wipe a buffer

string
randombytes_buf(int $length)

Generate a string of random bytes /dev/urandom

int
randombytes_random16()

Generate a 16-bit integer /dev/urandom

int
randombytes_uniform(int $upperBoundNonInclusive)

Generate an unbiased random integer between 0 and a specified value /dev/urandom

string
version_string()

Get the version string