Skip to content

Commit

Permalink
add support for additional digest types
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Oct 28, 2021
1 parent d806cf5 commit 205d3a0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/util/hash/wasm-hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ class WasmHash {
const { exports, buffered, mem, digestSize } = this;
exports.final(buffered);
this.instancesPool.push(this);
return mem.toString("latin1", 0, digestSize);
const hex = mem.toString("latin1", 0, digestSize);
if (type === "hex") return hex;
if (type === "binary" || !type) return Buffer.from(hex, "hex");
return Buffer.from(hex, "hex").toString(type);
}
}

Expand Down

0 comments on commit 205d3a0

Please sign in to comment.