From 451ac8ec83e7ceb2e14cc91a75220dba4621aafb Mon Sep 17 00:00:00 2001 From: Qiea Date: Sun, 22 Dec 2024 01:19:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=20test.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test.py | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 test.py diff --git a/test.py b/test.py deleted file mode 100644 index 0f6b1c7..0000000 --- a/test.py +++ /dev/null @@ -1,16 +0,0 @@ -def hamming_distance(hash1, hash2): - # 将哈希值转换为二进制字符串 - bin1 = bin(int(hash1, 16))[2:].zfill(len(hash1) * 4) # 16进制转二进制 - bin2 = bin(int(hash2, 16))[2:].zfill(len(hash2) * 4) - - # 计算汉明距离 - return sum(c1 != c2 for c1, c2 in zip(bin1, bin2)) - - -# 给定的两个哈希值 -hash1 = 'ffffff7060606000' -hash2 = '000034e3ffffffbf' - -# 计算汉明距离 -distance = hamming_distance(hash1, hash2) -print(f'汉明距离: {distance}')