You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
695 B
24 lines
695 B
const Service = require("egg").Service;
|
|
const SHA256 = require("sha256");
|
|
|
|
class UtilsService extends Service {
|
|
//密码加密
|
|
async encodePwd(password, params, bol) {
|
|
let newPassword = "";
|
|
if (bol) {
|
|
let newPasswordTemp = SHA256(params.userName + params.salt + password);
|
|
newPassword = SHA256(newPasswordTemp + params.challenge);
|
|
for (let n = 2; params.iIterate > n; n++) {
|
|
newPassword = SHA256(newPassword);
|
|
}
|
|
} else {
|
|
newPassword = SHA256(password) + params.challenge;
|
|
for (let n = 1; params.iIterate > n; n++) {
|
|
newPassword = SHA256(newPassword);
|
|
}
|
|
}
|
|
return newPassword;
|
|
}
|
|
}
|
|
|
|
module.exports = UtilsService;
|
|
|