UNPKG

balloon_hash

Version:

A secure WebAssembly-based implementation of Balloon Hashing (RFC 9197)

31 lines 1.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BalloonHash = void 0; const balloon_hash_1 = require("../pkg/balloon_hash"); class BalloonHash { constructor(spaceCost, timeCost, parallelCost) { this.instance = new balloon_hash_1.BalloonHash(spaceCost, timeCost, parallelCost); } /** * 주어진 비밀번호와 솔트를 사용하여 해시를 생성합니다. * @param password - 해시할 비밀번호 * @param salt - 솔트 값 * @returns 해시된 결과 (Uint8Array) */ hash(password, salt) { const passwordBuffer = this.toUint8Array(password); const saltBuffer = this.toUint8Array(salt); return this.instance.hash(passwordBuffer, saltBuffer); } /** * 문자열 또는 Uint8Array를 Uint8Array로 변환합니다. */ toUint8Array(input) { if (input instanceof Uint8Array) { return input; } return new TextEncoder().encode(input); } } exports.BalloonHash = BalloonHash; //# sourceMappingURL=balloon_hash.js.map