def YY_decode(cipher):
charList = [chr(i) for i in range(ord('A'), ord('Z') + 1)]
ret = []
plaintext = [i for i in cipher.split('0')]
for i in plaintext:
tmp = 0
for j in range(len(i)):
tmp += int(i[j])
ret.append(charList[(tmp - 1)])
return ''.join(ret)
def YY_encode(plaintext):
charList = [chr(i) for i in range(ord('A'), ord('Z') + 1)]
cipher = [i for i in plaintext]
tmp = []
ret = []
for i in range(len(cipher)):
for j in range(len(charList)):
if charList[j] == cipher[i]:
tmp.append(j + 1)
continue
for i in tmp:
res = ''
if i >= 8:
res += int(i / 8) * '8'
if i % 8 >= 4:
res += int(i % 8 / 4) * '4'
if i % 4 >= 2:
res += int(i % 4 / 2) * '2'
if i % 2 >= 1:
res += int(i % 2 / 1) * '1'
ret.append(res + '0')
return ''.join(ret)[:-1]