14 lines
554 B
Python
14 lines
554 B
Python
TABLE = 'ёйцукенгшщзхъфывапролджэячсмитьбюЁЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ1234567890-_. '
|
||
NUMBER = lambda n: str(n) if n > 9 else '0'+str(n)
|
||
|
||
def encode(text: str) -> str:
|
||
return ''.join([
|
||
NUMBER(TABLE.index(char)) if char in TABLE else char
|
||
for char in text
|
||
])
|
||
|
||
def decode(text: str) -> str:
|
||
return ''.join([
|
||
TABLE[int(text[index:index+2])] if text[index:index+2].isdigit() else text[index:index+2]
|
||
for index in range(0, len(text), 2)
|
||
])
|