def test_md5(self): import md5 stuff = RAND_pseudo_bytes(500)[0] for n in range(500): self.assertEqual( hashlib.md5(stuff[:n]).hexdigest(), md5.MD5(stuff[:n]).hexdigest())
def createCollisionBlock(prefix): digester = md5.MD5() digester.update(prefix) ihv = binascii.hexlify(digester.ihv()).decode() f0 = "block0" f1 = "block1" os.system("./fastcoll --ihv {} -o {} {}".format(ihv, f0, f1)) with open(f0, 'rb') as f0d: b0 = f0d.read() with open(f1, 'rb') as f1d: b1 = f1d.read() os.system("rm {}".format(f0)) os.system("rm {}".format(f1)) return b0, b1
def sign_req(values, secret): s = secret for k, v in sorted(values.items()): s += k s += v return md5.MD5(s).hexdigest()