String.fingerprint
fingerprint($algo='sha256') -> string
Description
Compute a unique one-way hash, or fingerprint of the string.
- The hash will always be the same for a given input string.
- The hash can not be “decrypted” back to its original plaintext.
- The hash will be the same length, regardless of the original plaintext.
SecurityDo NOT use this method for passwords. Use a Password object instead.
$prevHash = 'a591a6d40bf420404a011733cfb7b1...' $fileContent = File.read('importantFile.txt', { join }) $currentHash = $fileContent.hash() if $currentHash != $prevHash { // File content has been changed }
Supported Algorithms
By default, this method uses the SHA-256 algorithm, but can
md2 md4 md5 sha1 sha224 sha256 sha384 sha512/224 sha512/256 sha512 sha3-224 sha3-256 sha3-384 sha3-512 crc32 crc32b crc32c