Class: Sha256

Sha256

SHA-256 hash function reference implementation. This is an annotated direct implementation of FIPS 180-4, without any optimisations. It is intended to aid understanding of the algorithm rather than for production use. While it could be used where performance is not critical, I would recommend using the ‘Web Cryptography API’ (developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest) for the browser, or the ‘crypto’ library (nodejs.org/api/crypto.html#crypto_class_hash) in Node.js. See csrc.nist.gov/groups/ST/toolkit/secure_hashing.html csrc.nist.gov/groups/ST/toolkit/examples.html

Constructor

new Sha256()

Source:

Methods

(static) hash(msg, optionsopt) → {string}

Generates SHA-256 hash of string.
Parameters:
Name Type Attributes Description
msg string (Unicode) string to be hashed.
options Object <optional>
Properties
Name Type Attributes Default Description
msgFormat string <optional>
string Message format: 'string' for JavaScript string (gets converted to UTF-8 for hashing); 'hex-bytes' for string of hex bytes ('616263' ≡ 'abc') .
outFormat string <optional>
hex Output format: 'hex' for string of contiguous hex bytes; 'hex-w' for grouping hex bytes into groups of (4 byte / 8 character) words.
Source:
Returns:
Hash of msg as hex character string.
Type
string

(private, static) ROTR()

Rotates right (circular right shift) value x by n positions [§3.2.4].
Source:

(private, static) Σ0()

Logical functions [§4.1.2].
Source: