md5-analyzer init
This commit is contained in:
parent
46d7dd331a
commit
773d7f6366
|
@ -1,14 +1,12 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
"""
|
||||
This script is really bad and hacky, don't expect it to do anything.
|
||||
you also need the chiffrat.txt file in the same directory.
|
||||
|
||||
License: MIT
|
||||
author: Christoph J. Scherr <software@cscherr.de>
|
||||
source: https://git.cscherr.de/PlexSheep/python-dhbw/src/branch/master/src/basic-decrypt.py
|
||||
@license: MIT
|
||||
@author: Christoph J. Scherr <software@cscherr.de>
|
||||
@source: https://git.cscherr.de/PlexSheep/python-dhbw/src/branch/master/src/basic-decrypt.py
|
||||
"""
|
||||
|
||||
MAX_IN_LINE = 16
|
||||
DE_MOST_COMMON = ['E', 'N', 'I', 'R', 'A']
|
||||
EN_MOST_COMMON = ['E', 'T', 'A', 'O', 'I']
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
# this is literal garbage
|
||||
# does not even work for the bad hash
|
||||
def calcHash():
|
||||
message = list('A' * 4)
|
||||
|
||||
accu = int("a5a5a5a55a5a5a5a55555555aaaaaaaa", 16)
|
||||
|
||||
for i in range(0, len(message)):
|
||||
message[i] = hex(ord(message[i]))[2:]
|
||||
|
||||
if len(message) % 16 != 0:
|
||||
remainder = -((len(message) % 16) - 16);
|
||||
for i in range(0, remainder):
|
||||
message.append("FF")
|
||||
|
||||
chunks = []
|
||||
|
||||
for i in range(0, len(message), 16):
|
||||
chunk = "".join(message[i:i+16])
|
||||
chunks.append(chunk)
|
||||
|
||||
for B in chunks:
|
||||
accu = accu ^ int(B, 16)
|
||||
|
||||
print(accu)
|
||||
return accu
|
||||
|
||||
calcHash()
|
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
A small script to help analyze the md5 hash function.
|
||||
|
||||
@author Christoph J. Scherr <software@cscherr.de>
|
||||
@license MIT
|
||||
@source: https://git.cscherr.de/PlexSheep/python-dhbw/src/branch/master/src/md5-analyzer.py
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(prog="md5-analyzer", description='md5 analyzer for a cryptography assignment')
|
||||
parser.add_argument('--hash', type=str,
|
||||
help='an input that should be hashed.')
|
||||
args = parser.parse_args()
|
||||
if args.hash:
|
||||
print("Hash for '%s':\n%s" % (
|
||||
args.hash,
|
||||
hashlib.md5(args.hash.encode()).digest().hex()
|
||||
))
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -2,9 +2,9 @@
|
|||
"""
|
||||
Dirty hash we covered in an excercise for Week 16 of 2023 in cryptography
|
||||
|
||||
author: Christoph J. Scherr <software@cscherr.de>
|
||||
version control at: https://git.cscherr.de/PlexSheep/python-dhbw/src/branch/master/src/trash-hash.py
|
||||
License: MIT
|
||||
@author: Christoph J. Scherr <software@cscherr.de>
|
||||
@source: https://git.cscherr.de/PlexSheep/python-dhbw/src/branch/master/src/trash-hash.py
|
||||
@license: MIT
|
||||
"""
|
||||
import math
|
||||
import argparse
|
||||
|
|
Loading…
Reference in New Issue