
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
node-cubehash
Advanced tools
THIS LIBRARY IS MEANT AS A REFERENCE IMPLEMENTATION. A REFERENCE IMPLEMENTATION. I AM NOT AN EXPERIENCED CRYPTOGRAPHER AND I CANNOT GUARANTEE THAT THIS LIBRARY IS SECURE. DO NOT USE THIS FOR ANYTHING IMPORTANT! YOU HAVE BEEN WARNED.
cubehash is an ARX cryptographic hash function by DJB, which was submitted to the SHA-3 competition but did not make it to the finalists. i found it rather interesting and wanted to write an implementation of it. currently, the cryptanalysis seems rather promising (although there hasn't been much since the early 2010s). cubehash is simple to implement and has some nice features, like being able to change the number of rounds, size of input blocks, digest length, etc. however, there seems to be no good implementation of cubehash in JS. this library is meant as a reference for future JS implementations of cubehash. this implementation has no dependencies and is well commented for future reference.
browser:
<script src="https://cdn.jsdelivr.net/npm/node-cubehash/index.js"> in your code. window.CubeHash will be set to the CubeHash class.node:
npm i --save node-cubehash will install cubehash for you.the module.exports of this library (or window.CubeHash if you include index.js in the browser) is a class called CubeHash. its methods are provided below for reference.
constructor() - sets the parameters for CubeHash512, or CubeHash16+16/32+32-512, and precomputes the initialization vector. this is a sane default and no further configuration is required after creating the object.constructor(Number i, Number r, Number b, Number f, Number h) - sets the parameters for CubeHashi+r/b+f-h and precomputes the initialization vector (to know what this means, click here). NOTE THAT NO INPUT CHECKING IS DONE ON THE PARAMETERS AND YOU SHOULD VERIFY THAT THEY ARE CORRECT YOURSELF. i should be a member of the set {1,2,3,...}, r should be a member of the set {1,2,3,...}, b should be a member of the set {1,2,3,...,128}, f should be a member of the set {1,2,3,...}, and h should be a member of the set {8,16,24,...,512}.Uint8Array hash(Uint8Array m) - returns the hash for m with the parameters specified in the constructor.Uint8Array mac(Uint8Array message, Uint8Array key) - returns the CubeMAC with key key and message message with the parameters specified in the constructor. the key must be 512 bits (64 bytes). for more information, click here.reference usage:
// require cubehash
const CubeHash = require("node-cubehash");
// create a new cubehash object. cubehash512 by default.
const cubehash512 = new CubeHash();
// create a message uint8array
let message = new Uint8Array(Buffer.from("cubehash"));
// compute our hash
let rawHash = cubehash512.hash(message);
// log our hash as base64
console.log(Buffer.from(rawHash).toString("base64"));
run npm test or node test to run the test suite. the test suite includes a speedtest and verifies the output based on certain test vectors (found here).
most implementations of cubehash seem to be rather scarcely commented. this implementation is well commented. for further reference, read the specification.
FAQs
A pure JavaScript implementation of CubeHash.
The npm package node-cubehash receives a total of 2 weekly downloads. As such, node-cubehash popularity was classified as not popular.
We found that node-cubehash demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.