Skip to content

Commit

Permalink
Correctly pad numbers in browser hashing (parcel-bundler#7415)
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic authored and bhovhannes committed Dec 23, 2021
1 parent a881a8c commit 5ac8141
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/utils/hash/browser.js
Expand Up @@ -8,7 +8,7 @@ module.exports.init = (xxhash().then(xxh => {

const encoder = new TextEncoder();
function hashString(s /*: string */) /*: string */ {
return h64(s);
return h64(s).padStart(16, '0');
}
module.exports.hashString = hashString;
function hashBuffer(b /*: Uint8Array */) /*: string */ {
Expand Down Expand Up @@ -49,7 +49,7 @@ function concatUint8Arrays(arrays) {
function toHex(arr) {
let dataView = new DataView(arr.buffer);
return (
dataView.getUint32(0, true).toString(16) +
dataView.getUint32(4, true).toString(16)
dataView.getUint32(0, true).toString(16).padStart(8, '0') +
dataView.getUint32(4, true).toString(16).padStart(8, '0')
);
}

0 comments on commit 5ac8141

Please sign in to comment.