2021-11-02 14:11:20 -04:00
|
|
|
import { BinaryToTextEncoding, createHash } from 'crypto'
|
|
|
|
|
|
|
|
function sha256 (str: string | Buffer, encoding: BinaryToTextEncoding = 'hex') {
|
|
|
|
return createHash('sha256').update(str).digest(encoding)
|
|
|
|
}
|
|
|
|
|
|
|
|
function sha1 (str: string | Buffer, encoding: BinaryToTextEncoding = 'hex') {
|
|
|
|
return createHash('sha1').update(str).digest(encoding)
|
|
|
|
}
|
|
|
|
|
2021-12-17 05:58:15 -05:00
|
|
|
// high excluded
|
|
|
|
function randomInt (low: number, high: number) {
|
|
|
|
return Math.floor(Math.random() * (high - low) + low)
|
|
|
|
}
|
|
|
|
|
2021-11-02 14:11:20 -04:00
|
|
|
export {
|
2021-12-17 05:58:15 -05:00
|
|
|
randomInt,
|
2021-11-02 14:11:20 -04:00
|
|
|
sha256,
|
|
|
|
sha1
|
|
|
|
}
|