Version: v0.8.1 - Beta.  We welcome contributors & feedback.

String.fingerprint

fingerprint($algo='sha256') -> string

Description

Compute a unique one-way hash, or fingerprint of the string.

$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

See Also