2018-06-13 22:39:39 +03:00
|
|
|
'use strict';
|
|
|
|
|
2018-06-23 03:30:50 +03:00
|
|
|
import hash from 'hash.js';
|
2018-06-13 22:39:39 +03:00
|
|
|
|
2018-07-16 10:27:49 +03:00
|
|
|
import { arrayify } from './bytes';
|
|
|
|
|
|
|
|
import { Arrayish } from './types';
|
2018-06-13 22:39:39 +03:00
|
|
|
|
2018-06-15 11:18:17 +03:00
|
|
|
export function sha256(data: Arrayish): string {
|
2018-06-23 03:30:50 +03:00
|
|
|
return '0x' + (hash.sha256().update(arrayify(data)).digest('hex'));
|
2018-06-13 22:39:39 +03:00
|
|
|
}
|
|
|
|
|
2018-06-15 11:18:17 +03:00
|
|
|
export function sha512(data: Arrayish): string {
|
2018-06-23 03:30:50 +03:00
|
|
|
return '0x' + (hash.sha512().update(arrayify(data)).digest('hex'));
|
2018-06-13 22:39:39 +03:00
|
|
|
}
|