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

String.fingerprint

fingerprint() -> string

Description

Compute a unique, one-way hash of the string, using the SHA-256 algorithm.

A hashed string can not be decrypted back to its plaintext.

It will always be 64 characters long, regardless of the input length.

The hash will always be the same for a given input string.

$prevHash = 'a591a6d40bf420404a011733cfb7b1...'

$fileContent = File.read('importantFile.txt', true)
$currentHash = $fileContent.fingerprint()

if $currentHash != $prevHash {
    // File content has been changed
}

See Also