Skip to content

Commit

Permalink
jsdocify
Browse files Browse the repository at this point in the history
  • Loading branch information
brontolosone committed Jan 8, 2025
1 parent cb6a021 commit 6628199
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/xpath/src/functions/xforms/node-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,14 +410,16 @@ export const randomize = new NodeSetFunction(
);

const toBigIntHash = (text: string): bigint => {
// Hash text with sha256, and interpret the first 64 bits of output
// (the first and second int32s ("words") of CryptoJS digest output)
// as an int64 (in JS represented in a BigInt).
// Thus the entropy of the hash is reduced to 64 bits, which
// for some applications is sufficient.
// The underlying representations are big-endian regardless of the endianness
// of the machine this runs on, as is the equivalent JavaRosa implementation
// at https://github.com/getodk/javarosa/blob/ab0e8f4da6ad8180ac7ede5bc939f3f261c16edf/src/main/java/org/javarosa/xpath/expr/XPathFuncExpr.java#L718-L726
/**
Hash text with sha256, and interpret the first 64 bits of output
(the first and second int32s ("words") of CryptoJS digest output)
as an int64 (in JS represented in a BigInt).
Thus the entropy of the hash is reduced to 64 bits, which
for some applications is sufficient.
The underlying representations are big-endian regardless of the endianness
of the machine this runs on, as is the equivalent JavaRosa implementation.
({@link https://github.com/getodk/javarosa/blob/ab0e8f4da6ad8180ac7ede5bc939f3f261c16edf/src/main/java/org/javarosa/xpath/expr/XPathFuncExpr.java#L718-L726 | see here}).
*/
const buffer = new ArrayBuffer(8);
const dataview = new DataView(buffer);
SHA256(text)
Expand Down

0 comments on commit 6628199

Please sign in to comment.