cryptopals S1-4

题目:

https://cryptopals.com/sets/1/challenges/4

解法:

legal_chars = "01234567890abcdefghijklmnopgrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ "

with open("f:\\4.txt") as fin:
    for line in fin.readlines():
        x = bytes.fromhex(line.strip())
        for i in range(256):
            y = [chr(i^sx) for sx in x]
            if len([c for c in y if c in legal_chars]) > 0.8 * len(x):
                print(line, i, ''.join(y))

 

感想:

没有仔细读题,还以为就是S1-3的放大版

猜你喜欢

转载自www.cnblogs.com/xuesu/p/12000318.html