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 |
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
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. First 10 hashes;
(i.10) { hashes
98973283b3af42f7aa10372df7d62652
a7460a6feb4205c9ae7ca77f867fdc3b
1545446bd3903d812f5a5826727ef53a
fdcba9439b2d86e1b59a6edb4af37a52
7e7ad7a858a4368351846dfa8044e2f6
a9dfffd098cd64b5a8c26575a43ecc26
0897c50557a8202f26083f2bf3d0c7a2
bbb63a0d9c3fa5ea9ead2c6abbdb5017
54fe0d6b2c91024ca6d2762e629b9559
3555724e95175a629e15d90df1c25ccc
...