updated IS codes

This commit is contained in:
sherlock 2025-09-09 04:16:24 +05:30
parent a5c9c120ff
commit 13bcfbbafd
7 changed files with 356 additions and 1 deletions

View file

@ -0,0 +1,29 @@
import socket
import hashlib
def main() -> None:
host = "127.0.0.1"
port = 5001
message = b"hello integrity"
tamper = False # change to True to simulate corruption
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((host, port))
send_data = message if not tamper else message[:-1] + b"X"
s.sendall(send_data)
server_digest = s.recv(128).decode()
local_digest = hashlib.sha256(message).hexdigest()
ok = (server_digest == local_digest)
print("server:", server_digest)
print("local :", local_digest)
print("match :", ok)
if __name__ == "__main__":
main()