libsodium

Sodium is a modern, easy-to-use software library for encryption, decryption, signatures, password hashing and more.

The library is integrated into PHP as an extension. It provides a lot of functions and features to the language.

<?php
//Generate a random key for sodium_crypto_auth
$key = sodium_crypto_auth_keygen();

?>

Documentation

See also libsodium on github

Related : Cryptography, OpenSSL