Repository URL to install this package:
|
Version:
3.2.1 ▾
|
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
// @todo in another file
const crypto_1 = require("crypto");
const create = algorithm => (buffer, opts = {}) => __awaiter(this, void 0, void 0, function* () {
const options = Object.assign({
outputFormat: 'hex',
}, opts);
const hash = crypto_1.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');
function toPassword(password) {
return __awaiter(this, void 0, void 0, function* () {
if (process.env.SKAVA123) {
return 'Skava@123';
}
else {
const hashed = yield sha512(password || '@@empty');
// @todo just check if it contains a number and aZ cool
return hashed.slice(0, 27) + '@1aZ';
}
});
}
exports.toPassword = toPassword;
//# sourceMappingURL=fromPasswordToHashed.js.map