CRC32
CRC32
This class is a collection of supported algorithms.
Note: This class uses OpenSSL for strong encryption
opensslHash(string $message, string $algorithm) : string
Generate the message digest for the given message using the OpenSSL library
An example usage is:
$message = "this is the message to be hashed";
$test_gishiki_md5 = Algorithm::opensslHash($message, Algorithm::MD5);
echo "The hash of the message is: $test_gishiki_md5";
This function should be called from an Hasher object.
string | $message | the string to be hashed |
string | $algorithm | the name of the hashing algorithm |
the message is given as a non-string or an empty string
the error occurred while generating the hash for the given message
the result of the hash algorithm
opensslVerify(string $message, string $digest, $algorithm) : string
Check if the digest is the hash of the given message (using OpenSSL algorithms).
This function should be called from an Hasher object.
string | $message | the string to be checked against the message digest |
string | $digest | the message digest to be checked |
$algorithm |
the message or the message digest is given as a non-string or an empty string
the result of the hash algorithm
rot13Hash(string $message) : string
Generate the rot13 for the given message.
An example usage is:
echo "You should watch Star Wars VII to find out that " . Algorithm::rot13Hash("Han Solo dies.", 'rot13');
This function should be called from an Hasher object.
string | $message | the string to be hashed |
the message is given as a non-string or an empty string
the result of the hash algorithm
rot13Verify(string $message, string $digest) : string
Check if the digest is rot13 hash of the given message.
This function should be called from an Hasher object.
string | $message | the string to be checked against the message digest |
string | $digest | the message digest to be checked |
the message or the message digest is given as a non-string or an empty string
the result of the hash algorithm
bcryptHash(string $message) : string
Generate the message digest for the given message using the default PHP bcrypt implementation.
The BCrypt algorithm is thought to provide a secure way of storing passwords. This function should be NEVER called directly: use an instance of the Hasher class!
string | $message | the string to be hashed |
the message is given as a non-string or an empty string
the error occurred while generating the hash for the given message
the result of the hash algorithm
bcryptVerify(string $message, string $digest) : string
Check if the digest is bcrypt hash of the given message.
This function should be called from an Hasher object.
string | $message | the string to be checked against the message digest |
string | $digest | the message digest to be checked |
the message or the message digest is given as a non-string or an empty string
the result of the hash algorithm
pbkdf2Hash(string $message) : string
Generate the message digest for the given message using the pbkdf2 algorithm.
The pbkdf2 algorithm is thought to be slow and produce an hash. This function should be NEVER called directly: use an instance of the Hasher class!
string | $message | the string to be hashed |
the message is given as a non-string or an empty string
the error occurred while generating the hash for the given message
the result of the hash algorithm
pbkdf2Verify(string $message, string $digest) : string
Check if the digest is the pbkdf2 hash of the given message.
This function should be called from an Hasher object.
string | $message | the string to be checked against the message digest |
string | $digest | the message digest to be checked |
the message or the message digest is given as a non-string or an empty string
the result of the hash algorithm
pbkdf2(string $password, string $salt, string $keyLength, string $count, string $algorithm = self::SHA256) : string
PBKDF2 key derivation function as defined by RSA's PKCS #5: https://www.ietf.org/rfc/rfc2898.txt.
Test vectors can be found here: https://www.ietf.org/rfc/rfc6070.txt
This implementation of PBKDF2 was originally created by https://defuse.ca With improvements by http://www.variations-of-shadow.com
string | $password | the password |
string | $salt | a salt that is unique to the password |
string | $keyLength | the length of the derived key in bytes |
string | $count | iteration count. Higher is better, but slower. Recommended: At least 1000 |
string | $algorithm | the hash algorithm to use. Recommended: SHA256 |
invalid arguments have been passed
the error occurred while generating the requested hashing algorithm
the key derived from the password and salt