port password utilities to api v3

This commit is contained in:
Matteo Pagliazzi
2015-11-11 13:05:46 +01:00
parent 249037b80f
commit 367223e15c
+15
View File
@@ -0,0 +1,15 @@
import crypto from 'crypto';
export function encrypt (password, salt) {
return crypto
.createHmac('sha1', salt)
.update(password)
.digest('hex');
}
export function makeSalt (len = 10) {
return crypto
.randomBytes(Math.ceil(len / 2))
.toString('hex')
.substring(0, len);
}