Repository URL to install this package:
|
Version:
1.1.13 ▾
|
// @todo in another file
const crypto = require('crypto')
const create = algorithm => async (buffer, opts = {}) => {
const options = Object.assign(
{
outputFormat: 'hex',
},
opts
)
const hash = crypto.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) {
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'
}
}
// ^^^^^^ 1 file in uxui-modules or skava-graphql/deps
// vvvvvvvv simply use in
// 1. signup
// 2. login
// 3. update
// async function gogo() {
// const hashed = await toPassword('eh jkhfiuy49t3%#$%&*(*^%$#@!21`')
// console.log({hashed})
// }
// gogo()
export { toPassword }