下面附上函數代碼,求解出flag值 key值已經給出,求幫助啊,逆推過程應該怎麼寫啊
import base64
def encode(flag):
l1 = []
for a in flag:
l1.append(chr(int(ord(a)) - 10))
l1.reverse()#反向存儲
mid = ''.join(list(l1))
key = base64.b64encode(mid)
print key
key = 'YmVVJ2ReT2ZqZVVpWSY=='
上邊的代碼縮進有點問題 代碼在這裡http://paste.ubuntu.com/23493247/
import base64
def encode(flag):
tmp_list = []
for a in flag:
tmp_list.append(chr(int(ord(a)) - 10))
tmp_list.reverse()
mid = ''.join(list(tmp_list))
key = base64.b64encode(mid)
return key
def decode(value):
tmp_str = base64.b64decode(value)
lists = list(tmp_str)
lists.reverse()
new_list = []
for x in lists:
tmp_x = chr(ord(x) + 10)
new_list.append(tmp_x)
new_list.reverse()
new_list.reverse()
print new_list
if name == '__main__':
strs = "123"
value = encode(strs)
ori_str = decode(value)