Sha256
Extends:
src/hasher/hasher32be.js~Hasher32be → Sha256
Calculates SHA256 (SHA224) hash
Example:
import Sha256 from "crypto-api/src/hasher/sha256";
import {toHex} from "crypto-api/src/encoder/hex";
let hasher = new Sha256();
hasher.update('message');
console.log(toHex(hasher.finalize()));
import Sha256 from "crypto-api/src/hasher/sha256";
import {toHex} from "crypto-api/src/encoder/hex";
import {fromUtf} from "crypto-api/src/encoder/utf";
let hasher = new Sha256();
hasher.update(fromUtf('message'));
console.log(toHex(hasher.finalize()));
<script src="https://nf404.github.io/crypto-api/crypto-api.min.js"></script>
<script>
var hasher = CryptoApi.getHasher('sha256');
hasher.update('message');
console.log(CryptoApi.encoder.toHex(hasher.finalize()));
</script>
<script src="https://nf404.github.io/crypto-api/crypto-api.min.js"></script>
<script>
console.log(CryptoApi.hash('sha256', 'message'));
</script>
Constructor Summary
Public Constructor | ||
public |
constructor(options: Object) |
Method Summary
Public Methods | ||
public |
finalize(): string Finalize hash and return result |
|
public |
reset() Reset hasher to initial state |
Public Constructors
public constructor(options: Object) source
Params:
Name | Type | Attribute | Description | ||||||
options | Object |
|
|||||||
options.rounds | number |
|
Number of rounds (Must be greater than 16) |
||||||
options.length | number |
|
Length of hash result
|