这是题目给的代码,还有返回值fR4aHWwuFCYYVydFRxMqHhhCKBseH1dbFygrRxIWJ1UYFhotFjA=
- # -*- coding: UTF-8 -*-
- import base64
- # import hashlib
- '''
- def eccrypt(data):
- key = hashlib.md5('ISCC').hexdigest()
- # print 'key-->', key
- x = 0
- char = ''
- data_len = len(data) # data的长度
- key_len = len(key) # key的长度
- for i in range(data_len):
- if x == key_len:
- x = 0
- char += key[x]
- x += 1
- # print 'char-->', char
- flag = ''
- for i in range(data_len):
- flag += chr((ord(data[i]))+(ord(char[i])) % 128)
- # print 'flag-->', flag
- return base64.b64encode(flag)
- '''
- def detrcy(b64):
- int_b64 = []
- b64de = base64.b64decode(b64)
- # print 'b64de-->', b64de
- # print 'len_b64de-->', len(b64de)
- for i in range(len(b64de)):
- int_b64.append(ord(b64de[i]))
- # print 'int_b64-->',int_b64
- # print 'len_int_b64-->', len(int_b64)
- key = '729623334f0aa2784a1599fd374c120d729623' # 知道data的长度后直接写出来
- int_key = []
- for i in range(len(key)):
- int_key.append(ord(key[i]))
- # print 'int_key-->', int_key
- flag = ''
- for i in range(len(int_b64)):
- flag += chr((int_b64[i]-int_key[i]+128) % 128)
- print flag
- if __name__ == '__main__':
- # str_b64 = eccrypt('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
- # print 'str_b64-->', str_b64
- str_b64 = 'fR4aHWwuFCYYVydFRxMqHhhCKBseH1dbFygrRxIWJ1UYFhotFjA='
- # print 'str_b64-->', str_b64
- detrcy(str_b64)
复制代码 解密的代码,得到flag |