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 SHA1#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 options
Object Optional options object (descriptions of parameters below) Properties
Name Type Argument Default Description return_format
string <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|SHA1}
-
Hashes data into the SHA1 class instance.
Parameters:
Name Type Argument Description data
string ASCII-encoded binary string data to hash. Any non-ASCII characters should be first encoded out using convert.utf8.encode options
Object <optional>
Optional options object Properties
Name Type Argument Default Description stream
boolean <optional>
false Whether to use streaming (progressive hashing) mode. In streaming mode, you can repeatedly hash data into the SHA1 object. The hash will not be finalized and returned until you call SHA1#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_format
string <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 | SHA1
-
initialize() → {SHA1}
-
This is called automatically on class instantiation.
Returns:
- Type
- SHA1