Repository URL to install this package:
|
Version:
2.0.12 ▾
|
// @todo in another file
import { createHash } from 'crypto'
const create = algorithm => async (buffer, opts = {}) => {
const options = Object.assign(
{
outputFormat: 'hex',
},
opts
)
const hash = createHash(algorithm)
hash.update(buffer, typeof buffer === 'string' ? 'utf8' : undefined)
if (options.outputFormat === 'hex') {
return hash.digest('hex')
}
return hash.digest().buffer
}
// @todo use a better sha @@security
const sha512 = create('sha512')
async function toPassword(password: string) {
if (process.env.SKAVA123) {
return 'Skava@123'
} else {
const hashed = await sha512(password || '@@empty')
// @todo just check if it contains a number and aZ cool
return hashed.slice(0, 27) + '@1aZ'
}
}
export { toPassword }