ethers.js/src.ts/utils/sha2.ts

21 lines
504 B
TypeScript

'use strict';
import hash from 'hash.js';
import { arrayify } from './bytes';
// Types
import { Arrayish } from './bytes';
export function ripemd160(data: Arrayish): string {
return '0x' + (hash.ripemd160().update(arrayify(data)).digest('hex'));
}
export function sha256(data: Arrayish): string {
return '0x' + (hash.sha256().update(arrayify(data)).digest('hex'));
}
export function sha512(data: Arrayish): string {
return '0x' + (hash.sha512().update(arrayify(data)).digest('hex'));
}