@darkwolf/hash
Version:
16 lines (13 loc) • 369 B
JavaScript
import crypto from 'crypto'
import Base58 from '@darkwolf/base58'
export default class Hash {
static createHash(key) {
const hash = crypto
.createHmac('sha256', key || crypto.randomBytes(64))
.digest('hex')
return Base58.encode(hash).slice(20, 84)
}
static createUid(key) {
return Hash.createHash(key).slice(20, 40)
}
}