Created
September 12, 2021 06:09
-
-
Save AshyIsMe/1c49716365f6ac07c0a74bad9f984ae7 to your computer and use it in GitHub Desktop.
md5 hashing in j
This file contains 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
0 : 0 | |
Can you crack Aaron’s password hash? He seems to like | |
simple passwords. I’m sure he’ll use his name and birthday | in it. Hint: Aaron writes important dates as YYYYMMDD | |
rather than YYYY-MM-DD or any other special character | separator. Hash: 7f4986da7d7b52fa81f98278e6ec9dcb. | |
Author: moat, Pacific Northwest National Laboratory | |
) | |
y=:":"0 (1900 + i.120) | |
m=:(i.11) { ('0' ,"1 ":"0 (1+i.9)) , ('1' ,"1 ":"0 (1+i.9)) | |
d=:('0' ,"1 ":"0 (1+i.9)) , (":"0) 10+i.22 | |
md5=:15&(128!:6) | |
NB. md5 'foo' | |
NB. acbd18db4cc2f85cedef654fccc4a4d8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
require 'format/printf'
dates=:,/ (1+i.31) ,"1 0/~ ,/ (1900+i.120) ,"0/ (1+i.12)
sdates =: '%d%02d%02d' sprintf dates
passwords=:'Aaron',"1 1 sdates
hashes=:md5 passwords
NB. Compare the needle with the haystack.
NB. This compares each character and returns a list of bools for each comparison.
NB. Then we sum the bits together.
sums =: +/"1 '7f4986da7d7b52fa81f98278e6ec9dcb' ="1 1 hashes
NB. Find the index of a match
sums i: 32
NB. Grab the matching password
(sums i: 32) { passwords