Home Reference Source Test
public class | source

Has160

Extends:

src/hasher/hasher32le.js~Hasher32le → Has160

Calculates HAS-160 hash

Example:

Calculates HAS-160 hash from string "message" - ES6 style
import Has160 from "crypto-api/src/hasher/has160";
import {toHex} from "crypto-api/src/encoder/hex";

let hasher = new Has160();
hasher.update('message');
console.log(toHex(hasher.finalize()));
Calculates HAS-160 hash from UTF string "message" - ES6 style
import Has160 from "crypto-api/src/hasher/has160";
import {toHex} from "crypto-api/src/encoder/hex";
import {fromUtf} from "crypto-api/src/encoder/utf";

let hasher = new Has160();
hasher.update(fromUtf('message'));
console.log(toHex(hasher.finalize()));
Calculates HAS-160 hash from string "message" - ES5 style
<script src="https://nf404.github.io/crypto-api/crypto-api.min.js"></script>
<script>
  var hasher = CryptoApi.getHasher('has160');
  hasher.update('message');
  console.log(CryptoApi.encoder.toHex(hasher.finalize()));
</script>
Calculates HAS-160 hash from UTF string "message" - ES5 style
<script src="https://nf404.github.io/crypto-api/crypto-api.min.js"></script>
<script>
  console.log(CryptoApi.hash('has160', 'message'));
</script>

Test:

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:

NameTypeAttributeDescription
options Object
  • optional
options.rounds number
  • optional
  • default: 80

Number of rounds (Can be from 1 to 80)

Public Methods

public finalize(): string source

Finalize hash and return result

Return:

string

public reset() source

Reset hasher to initial state