-
Notifications
You must be signed in to change notification settings - Fork 15
enhancement(cli): #1534 replace in-house hashString logic with Node createHash() #1564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
thescientist13
merged 14 commits into
ProjectEvergreen:master
from
shyok21:refactor/1534
Oct 16, 2025
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8c332d9
refactor: replace in-house hashString logic with Node createHash()
shyok21 9448d5e
fix: addressed reviewer feedback on regex usage
shyok21 f61b18b
fix: fix minor issues in regex patterns and test cases
shyok21 ebb4c35
fix: replaced hashing algorithm to shake256
shyok21 c83b10a
fix: fixed all test cases
shyok21 3276f7b
fix: replaced hashed output from hex to base64 for more security
shyok21 0a40dc1
fix: added test statement which was accidently removed
shyok21 b819dcd
fix: fixed test files for supporting hashing
shyok21 da95cc8
fix: updated etag hash to fix the test
shyok21 eb1f00d
fix: updated font-awesome regex to fix test failure
shyok21 3082068
fix: updated inline script test file
shyok21 b18cf39
refactor: added HASH_REGEX key in test utils
shyok21 762b9ec
refactor graphql data caching implementation
thescientist13 ca61ae4
fix: replaced hash digest to base64url
shyok21 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,15 @@ | ||
| // https://gist.github.com/hyamamoto/fd435505d29ebfa3d9716fd2be8d42f0#gistcomment-2775538 | ||
| function hashString(inputString) { | ||
| let h = 0; | ||
| import { createHash } from "node:crypto"; | ||
|
|
||
| for (let i = 0; i < inputString.length; i += 1) { | ||
| h = (Math.imul(31, h) + inputString.charCodeAt(i)) | 0; | ||
| } | ||
|
|
||
| return Math.abs(h).toString(); | ||
| /** | ||
| * Generates a hash of the input string. | ||
| * @param {string} inputString - The string to hash. | ||
| * @param {number} [bytes=6] - Number of bytes to be generated by the hash (default: 6). | ||
| * Note: This specifies the number of bytes, not the length of the hash. | ||
| * The hash length in characters depends on the bytes and is approximately `(bytes * 8 / 6)` when encoded in base64url. | ||
| * @returns {string} A base64url-encoded hash of the input string. | ||
| */ | ||
| function hashString(inputString, bytes = 6) { | ||
| return createHash("shake256", { outputLength: bytes }).update(inputString).digest("base64url"); | ||
| } | ||
|
|
||
| export { hashString }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.