2018-06-13 15:39:39 -04:00
|
|
|
'use strict';
|
|
|
|
|
2018-06-22 20:30:50 -04:00
|
|
|
import hash from 'hash.js';
|
2018-06-13 15:39:39 -04:00
|
|
|
|
2018-07-16 03:27:49 -04:00
|
|
|
import { arrayify } from './bytes';
|
|
|
|
|
2018-07-30 18:59:52 -04:00
|
|
|
// Types
|
|
|
|
import { Arrayish } from './bytes';
|
2018-06-13 15:39:39 -04:00
|
|
|
|
2019-02-01 18:39:50 -05:00
|
|
|
export function ripemd160(data: Arrayish): string {
|
|
|
|
return '0x' + (hash.ripemd160().update(arrayify(data)).digest('hex'));
|
|
|
|
}
|
|
|
|
|
2018-06-15 04:18:17 -04:00
|
|
|
export function sha256(data: Arrayish): string {
|
2018-06-22 20:30:50 -04:00
|
|
|
return '0x' + (hash.sha256().update(arrayify(data)).digest('hex'));
|
2018-06-13 15:39:39 -04:00
|
|
|
}
|
|
|
|
|
2018-06-15 04:18:17 -04:00
|
|
|
export function sha512(data: Arrayish): string {
|
2018-06-22 20:30:50 -04:00
|
|
|
return '0x' + (hash.sha512().update(arrayify(data)).digest('hex'));
|
2018-06-13 15:39:39 -04:00
|
|
|
}
|