diff --git a/src/basic-decrypt.py b/src/basic-decrypt.py index 34712a4..67ab9f7 100755 --- a/src/basic-decrypt.py +++ b/src/basic-decrypt.py @@ -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 -source: https://git.cscherr.de/PlexSheep/python-dhbw/src/branch/master/src/basic-decrypt.py +@license: MIT +@author: Christoph J. Scherr +@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'] diff --git a/src/calchash.py b/src/calchash.py deleted file mode 100755 index 0aaa8da..0000000 --- a/src/calchash.py +++ /dev/null @@ -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() diff --git a/src/md5-analyzer.py b/src/md5-analyzer.py new file mode 100755 index 0000000..5c02e35 --- /dev/null +++ b/src/md5-analyzer.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 +""" +A small script to help analyze the md5 hash function. + +@author Christoph J. Scherr +@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() diff --git a/src/trash-hash.py b/src/trash-hash.py index c34f876..5d3d523 100755 --- a/src/trash-hash.py +++ b/src/trash-hash.py @@ -2,9 +2,9 @@ """ Dirty hash we covered in an excercise for Week 16 of 2023 in cryptography -author: Christoph J. Scherr -version control at: https://git.cscherr.de/PlexSheep/python-dhbw/src/branch/master/src/trash-hash.py -License: MIT +@author: Christoph J. Scherr +@source: https://git.cscherr.de/PlexSheep/python-dhbw/src/branch/master/src/trash-hash.py +@license: MIT """ import math import argparse