@worker-tools/deno-kv-storage
Version:
An implementation of the StorageArea (1,2,3) interface for Deno with an extensible system for supporting various database backends.
24 lines • 1.09 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.hashMd5Password = void 0;
const deps_js_1 = require("../deps.js");
const encoder = new TextEncoder();
const decoder = new TextDecoder();
async function md5(bytes) {
return decoder.decode(deps_js_1.hex.encode(new Uint8Array(await deps_js_1.crypto.subtle.digest("MD5", bytes))));
}
// AuthenticationMD5Password
// The actual PasswordMessage can be computed in SQL as:
// concat('md5', md5(concat(md5(concat(password, username)), random-salt))).
// (Keep in mind the md5() function returns its result as a hex string.)
async function hashMd5Password(password, username, salt) {
const innerHash = await md5(encoder.encode(password + username));
const innerBytes = encoder.encode(innerHash);
const outerBuffer = new Uint8Array(innerBytes.length + salt.length);
outerBuffer.set(innerBytes);
outerBuffer.set(salt, innerBytes.length);
const outerHash = await md5(outerBuffer);
return "md5" + outerHash;
}
exports.hashMd5Password = hashMd5Password;
//# sourceMappingURL=auth.js.map
;