diff --git a/website/src/libs/api-v3/password.js b/website/src/libs/api-v3/password.js new file mode 100644 index 0000000000..b047aa2f0d --- /dev/null +++ b/website/src/libs/api-v3/password.js @@ -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); +} \ No newline at end of file