Extends
Requires
- module:convert
Methods
-
clear()
-
Initialize class values, invoking Hasher#clear before clearing values specific to SHA1. This is called internally at the end of SHA256#finalize, and can be called explicitly when using progressive hashing.
-
finalize(options) → {string|Array}
-
Finalizes the hash and returns the result. This is called internally by the hash method of the Hasher subclass instance when streaming mode is turned off. It should be called explicitly when using streaming mode after all data is passed into the hash method.
Parameters:
Name Type Description optionsObject Optional options object (descriptions of parameters below) Properties
Name Type Argument Default Description return_formatstring <optional>
hex (binary|hex|words) The return format. Default: hex - Inherited From:
- Source:
Returns:
A string or array depending on options.return_format- Type
- string | Array
-
get_block_size() → {number}
-
Returns the block size in bits for the current instance
- Inherited From:
- Source:
Returns:
The block size in bits.- Type
- number
-
get_outlen() → {number}
-
Returns the length in bits of the output block for this instance
- Inherited From:
- Source:
Returns:
The output block size in bits.- Type
- number
-
hash(data, options) → {string|Array|SHA256}
-
Hashes data into the SHA256 class instance.
Parameters:
Name Type Argument Description datastring ASCII-encoded binary string data to hash. Any non-ASCII characters should be first encoded out using convert.utf8.encode optionsObject <optional>
Optional options object Properties
Name Type Argument Default Description streamboolean <optional>
false Whether to use streaming (progressive hashing) mode. In streaming mode, you can repeatedly hash data into the SHA256 object. The hash will not be finalized and returned until you call SHA256#finalize. Streaming mode is useful when you have to hash a huge amount of data and you don't want to store all of it in memory at one time. return_formatstring <optional>
'hex' (binary|hex|words) The return format. Default: hex Returns:
Desired output format if streaming mode is turned off. Otherwise this instance (chainable)- Type
- string | Array | SHA256
-
initialize() → {SHA256}
-
This is called automatically on class instantiation.
Returns:
- Type
- SHA256