From 5d3c66f615075edecac355ad496f9e2022b6c9b4 Mon Sep 17 00:00:00 2001 From: n1474335 Date: Thu, 9 Mar 2023 18:06:32 +0000 Subject: [PATCH] Removed call to cptable from NTHash operation --- src/core/operations/NTHash.mjs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/core/operations/NTHash.mjs b/src/core/operations/NTHash.mjs index 51318135..bde7a24a 100644 --- a/src/core/operations/NTHash.mjs +++ b/src/core/operations/NTHash.mjs @@ -5,8 +5,6 @@ */ import Operation from "../Operation.mjs"; - -import cptable from "codepage"; import {runHash} from "../lib/Hash.mjs"; /** @@ -35,10 +33,14 @@ class NTHash extends Operation { * @returns {string} */ run(input, args) { - const format = 1200; // UTF-16LE - const encoded = cptable.utils.encode(format, input); - const hashed = runHash("md4", encoded); + // Convert to UTF-16LE + const buf = new ArrayBuffer(input.length * 2); + const bufView = new Uint16Array(buf); + for (let i = 0; i < input.length; i++) { + bufView[i] = input.charCodeAt(i); + } + const hashed = runHash("md4", buf); return hashed.toUpperCase(); } }