API Reference › Crypto › Crypto.sha256
method

Crypto.sha256

Crypto.sha256(s) -> string

Computes the SHA-256 digest of the bytes of s and returns it as a 64-character lowercase hex string. This is the standard, FIPS 180-4 algorithm — the same digest every other conforming implementation produces — so it is deterministic across platforms and runs and is backed by published known-answer vectors. Use it to fingerprint content, or as the building block under Crypto.hmac_sha256 for signing. On its own SHA-256 is not a message authentication code: anyone can recompute it, so it proves what the data is, not who produced it.

Parameters

sthe string whose bytes are hashed

Example

program Fingerprint {
  entry {
    let digest = Crypto.sha256("abc")
    print(digest)   # ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
  }
}
← All symbols