Skip to content

Instantly share code, notes, and snippets.

View timargra's full-sized avatar

timargra

  • sma dev
  • Jena, Germany
View GitHub Profile
@timargra
timargra / variableHash.js
Last active March 20, 2023 13:47 — forked from bminer/variableHash.js
Generate a variable-length hash of `data` in Node.js
var crypto = require("crypto");
/* variableHash - Generate a variable-length hash of `data`.
Adapted node version 8.x
------------------------
Similar to the answer here: http://crypto.stackexchange.com/a/3559/4829
If you want a b-bit hash of the message m, then use the first b bits of AES-CTR(SHA256(m)).
Rather than using the suggested algorithm in the stackexchange answer above, I developed