started lab5

This commit is contained in:
Student 2025-09-02 10:17:40 +05:30
parent 60ebd2b53c
commit f4f4b53f24
4 changed files with 41 additions and 0 deletions

31
IS/Lab/Lab5/customhash.py Normal file
View file

@ -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()

10
IS/Lab/Lab5/hashbench.py Normal file
View file

@ -0,0 +1,10 @@
import hashlib
def ds_gen(dsize):
def main():
dsize = int(input("Enter data size: "))
if __name__ == '__main__':
main()

View file

View file