for i in range(0,len(flag_int)/8): m = 0 for j in range(0,8): loc = i*8 + j if flag_int[loc] != -1: m = m + (flag_int[loc] << (5*(7-j)) ) for j in range(0,5): letter = ( m >> (8*(4-j))) & 0xff flag.append(chr(letter)) flag_str = "" for i in flag: flag_str = flag_str + i print flag_str
byte_40507C = range(0x41,0x41+26) byte_letter = [] for i in byte_40507C: byte_letter.append(i) defint_to_char(a): b = [] for i in a: b.append(chr(i)) return b deftranslate_str(byte_letter): for i in range(0,len(byte_letter)): v3 = byte_letter[i] if (v3 - 97) <= 0x19: byte_letter[i] = (v3 - 84) % 26 + 97; if (v3 - 65) <= 0x19: byte_letter[i] = (v3 - 52)% 26 + 65; return byte_letter print"letter",translate_str(byte_letter) byte_letter_2 = translate_str(byte_letter) for i in range(0,len(byte_letter_2)): if i % 2 == 1: byte_letter_2[i] += 32 for i in range(55,49,-1): byte_letter_2.append(i) encry_str = "" for i in byte_letter_2: encry_str += chr(i) #key = encry_str key = int_to_char(byte_letter_2)
byte_letter_l = range(96,96+26) trans_init = int_to_char(translate_str(byte_letter_l))##函数在上文中 dict_letter = {} j = 0 for i in range(96,96+26): dict_letter[trans_init[j]] = i j = j + 1 flag_new = [] for i in range(0,len(flag)): if flag[i] <= 'z'and flag[i] >= 'a': flag_new.append(dict_letter[flag[i]]) else: flag_new.append(ord(flag[i])) flag_str = "" for i in flag_new: flag_str += chr(i) print flag_str