diff --git a/IS/Lab/Lab5/customhash.py b/IS/Lab/Lab5/customhash.py new file mode 100644 index 0000000..be7dc93 --- /dev/null +++ b/IS/Lab/Lab5/customhash.py @@ -0,0 +1,31 @@ +import time + +MASK32 = 0xFFFFFFFF + +def hash_gen(s: str, h: int, mult: int): + """Compute hash of the whole string, print it each loop iteration, repeat.""" + try: + while True: + cur = h & MASK32 + for ch in s: + cur = (cur * mult + ord(ch)) & MASK32 + cur ^= (cur >> 16) + cur = (cur * 0x85ebca6b) & MASK32 + cur ^= (cur >> 13) + print(f"String: {s!r} Hash: {cur:#010x}") + h = cur + time.sleep(2) + except KeyboardInterrupt: + print("\nStopped.") + +def main(): + hash_init = int(input("Enter initial Hash value: ")) + hash_mult = int(input("Enter Hash Multiplier: ")) + + s = input("Enter String to Hash: ") + print("Welcome to the Hash Generatorâ„¢: ") + hash_gen(s, hash_init, hash_mult) + +if __name__ == '__main__': + main() + diff --git a/IS/Lab/Lab5/hashbench.py b/IS/Lab/Lab5/hashbench.py new file mode 100644 index 0000000..bc6009b --- /dev/null +++ b/IS/Lab/Lab5/hashbench.py @@ -0,0 +1,10 @@ +import hashlib + +def ds_gen(dsize): + + +def main(): + dsize = int(input("Enter data size: ")) + +if __name__ == '__main__': + main() diff --git a/IS/Lab/Lab5/socket/clienthash.py b/IS/Lab/Lab5/socket/clienthash.py new file mode 100644 index 0000000..e69de29 diff --git a/IS/Lab/Lab5/socket/serverhash.py b/IS/Lab/Lab5/socket/serverhash.py new file mode 100644 index 0000000..e69de29