crypt.Sha2 Extends goog.crypt.Hash
SHA-2 cryptographic hash constructor. This constructor should not be used directly to create the object. Rather, one should use the constructor of the sub-classes.

Inheritance

Constructor

goog.crypt.Sha2(numHashBlocksinitHashBlocks)

Parameters

numHashBlocks : number
The size of output in 16-byte blocks.
initHashBlocks : Array.<number>
The hash-specific initialization

Instance Methods

Public Protected Private
computeChunk_()
Helper function to compute the hashes for a given 512-bit message chunk.
code »
digest()
No description.
code »
reset()
No description.
code »
update()
No description.
code »
digest() !Array.<number>
No description.
Returns: !Array.<number>  The finalized hash computed from the internal accumulator.
code »
update(bytesopt_length)
Adds a byte array (array with values in [0-255] range) or a string (might only contain 8-bit, i.e., Latin1 characters) to the internal accumulator. Many hash functions operate on blocks of data and implement optimizations when a full chunk of data is readily available. Hence it is often preferable to provide large chunks of data (a kilobyte or more) than to repeatedly call the update method with few tens of bytes. If this is not possible, or not feasible, it might be good to provide data in multiplies of hash block size (often 64 bytes). Please see the implementation and performance tests of your favourite hash.
Arguments:
bytes : Array.<number> | Uint8Array | string
Data used for the update.
opt_length : number=
Number of bytes to use.
code »

Instance Properties

chunk_ :
A chunk holding the currently processed message bytes. Once the chunk has 64 bytes, we feed it into computeChunk_ function and reset this.chunk_.
Code »
constructor :
No description.
Code »
hash_ :
Holds the previous values of accumulated hash a-h in the computeChunk_ function.
Code »
inChunk_ :
Current number of bytes in this.chunk_.
Code »
initHashBlocks_ :
No description.
Code »
numHashBlocks_ :
The number of output hash blocks (each block is 4 bytes long).
Code »
total_ :
Total number of bytes in currently processed message.
Code »
w_ :
Temporary array used in chunk computation. Allocate here as a member rather than as a local within computeChunk_() as a performance optimization to reduce the number of allocations and reduce garbage collection.
Code »
blockSize :
The block size for the hasher.
Code »
reset :
Resets the internal accumulator.
Code »

Static Properties

goog.crypt.Sha2.BLOCKSIZE_ :
The block size
Code »
goog.crypt.Sha2.K_ :
Constants used in SHA-2.
Code »
goog.crypt.Sha2.Kx_ :
Sha2.K as an Int32Array if this JS supports typed arrays; otherwise, the same array as Sha2.K. The compiler cannot remove an Int32Array, even if it is not needed (There are certain cases where creating an Int32Array is not side-effect free). Instead, the first time we construct a Sha2 instance, we convert or assign Sha2.K as appropriate.
Code »
goog.crypt.Sha2.PADDING_ :
Contains data needed to pad messages less than BLOCK_SIZE_ bytes.
Code »
goog.crypt.Sha2.superClass_ :
No description.
Code »

Package crypt

Package Reference