1. Go to this page and download the library: Download fpoirotte/tomcrypt library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$algo = TOMCRYPT_HASH_SHA256;
// Returns the hash value for the given data in hexadecimal form
$hash = tomcrypt_hash_string($algo, $data, false);
// Returns the hash value for the given data in raw (binary) form
$hash = tomcrypt_hash_string($algo, $data, true);
// Returns the hash value for the given file in raw (binary) form
$hash = tomcrypt_hash_file($algo, "/tmp/file", true);
$algo1 = TOMCRYPT_MAC_HMAC;
$hash = TOMCRYPT_HASH_SHA1;
$key = "my secret key...";
$data = "some data here";
// Returns the HMAC for the given data in hexadecimal form,
// using the SHA-1 hashing algorithm.
$hmac = tomcrypt_mac_string($algo1, $hash, $key, $data, false);
// Returns the PMAC for the given data in raw (binary) form,
// using the Rijndael cipher algorithm.
$algo2 = TOMCRYPT_MAC_PMAC;
$cipher = TOMCRYPT_CIPHER_RIJNDAEL;
$pmac = tomcrypt_mac_string($algo2, $cipher, $key, $data, true);
// Returns the HMAC for the given file in raw (binary) form,
// using the SHA-1 hashing algorithm.
$hmac = tomcrypt_mac_file($algo1, $hash, $key, "/tmp/file", true);
// Attempt to get 42 bytes of purely random data.
// Returns FALSE if random data cannot be obtained in a secure way.
$random = tomcrypt_rng_get_bytes(42, TOMCRYPT_RNG_SECURE);