1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| def convert_md5(code,byte_n=8): """ 128位二进制字符串特征值转list,指定字节数 :param origin: "10100011011100101100101001100010101101111101101100101010100011001001011100100000011111011111110110001100111000010101001010110001" :return: [ 163, 114, 202, 98, 183, 219, 42, 140, 151, 32, 125, 253, 140, 225, 82, 177 ] """ result = [int(code[i:i + byte_n], 2) for i in range(len(code)) if i % byte_n == 0] return result
def int2bin(n, count=24): """ returns the binary of integer n, using count number of digits """ return "".join([str((n >> y) & 1) for y in range(count - 1, -1, -1)])
def unconvert_md5(origin,byte_n=8): """ 特征列表转化为128字符串 :param origin: [ 163, 114, 202, 98, 183, 219, 42, 140, 151, 32, 125, 253, 140, 225, 82, 177 ] :return: '10100011011100101100101001100010101101111101101100101010100011001001011100100000011111011111110110001100111000010101001010110001' """ return "".join([str(int2bin(i, 8)) for i in origin])
|