-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
feat: Added MD5 hashing algorithm #1519
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
Merged
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
cb4603c
feat: Added MD5 hashing algorithm
ManpreetXSingh 03466f2
Added wiki link
ManpreetXSingh 39bd146
Remove spam?
ManpreetXSingh 8244cf8
Fix extend towards end
ManpreetXSingh 6226cf4
Return Uint32Array in MD5 function
ManpreetXSingh f35a935
Preprocess function now works on uint arrays
ManpreetXSingh d33e1c4
chunkify U32Array instead of string
ManpreetXSingh b9201b2
Remove all string related functions
ManpreetXSingh 2a8daf7
Replace typed arrays with named variables
ManpreetXSingh d42ae6e
Fix "Replace typed arrays with named variables"
ManpreetXSingh af2684d
Return Uint8 Array in MD5 function
ManpreetXSingh 4a6ff69
Add tests
ManpreetXSingh c8d97df
Fix docstrings
ManpreetXSingh 62682ce
Introduce hexMD5 function
ManpreetXSingh efbd5cc
Change test string
ManpreetXSingh 5fdf178
Format test file
ManpreetXSingh 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
Add tests
- Loading branch information
commit 4a6ff6955a65f6a382602593055a73d3913fb6a2
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { MD5 } from '../MD5' | ||
|
||
describe('Testing MD5 function', () => { | ||
it('should return the correct hash for "The quick brown fox jumps over the lazy dog"', () => { | ||
const input = new TextEncoder().encode( | ||
'The quick brown fox jumps over the lazy dog' | ||
) | ||
|
||
const hash = Array.from(MD5(input), (byte) => | ||
byte.toString(16).padStart(2, '0') | ||
).join('') | ||
|
||
expect(hash).toBe('9e107d9d372bb6826bd81d3542a419d6') | ||
}) | ||
|
||
it('should return the correct hash for "The quick brown fox jumps over the lazy dog."', () => { | ||
ManpreetXSingh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const input = new TextEncoder().encode( | ||
'The quick brown fox jumps over the lazy dog.' | ||
) | ||
|
||
const hash = Array.from(MD5(input), (byte) => | ||
byte.toString(16).padStart(2, '0') | ||
).join('') | ||
|
||
expect(hash).toBe('e4d909c290d0fb1ca068ffaddf22cbd0') | ||
}) | ||
|
||
it('should correctly hash an empty string', () => { | ||
const input = new TextEncoder().encode('') | ||
|
||
const hash = Array.from(MD5(input), (byte) => | ||
byte.toString(16).padStart(2, '0') | ||
).join('') | ||
|
||
expect(hash).toBe('d41d8cd98f00b204e9800998ecf8427e') | ||
}) | ||
}) |
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.