@a11ywatch/core
Version:
a11ywatch central API
30 lines • 1.4 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.saltHashPassword = void 0;
const crypto_1 = require("crypto");
const generate_1 = require("./generate");
function sha512(password, salt) {
const hash = (0, crypto_1.createHmac)("sha512", salt);
hash.update(password);
return {
salt,
passwordHash: hash.digest("hex"),
};
}
function saltHashPassword(userpassword, saltIncluded) {
return __awaiter(this, void 0, void 0, function* () {
const salt = saltIncluded || (yield (0, generate_1.asyncRandomGenerate)(16));
return sha512(userpassword, salt);
});
}
exports.saltHashPassword = saltHashPassword;
//# sourceMappingURL=salt-hash.js.map
;