bb = bytearray("шЗЭШРЫУЫЮЙ".encode('WINDOWS-1251'))
for i in range(len(bb)):
bb[i] ^= 54
print(bb.decode('WINDOWS-1251')) # Осложнения
цчфхтурсюяьэъышщжздевгабопмнклийћЦЧФХТУРСЮЯЬЭЪЫШЩЖЗДЕВГАБОПМНКЛИЙЋ
АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯЁабвгдежзийклмнопрстуфхцчшщъыьэюяё
[12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
os.system("tar cvf backup/backup_month/%d.tar.gz * && rm backup/*" % ((datetime.date.today().month - 2) % 12 + 1))
import re
with open("блаблабла.txt", "rb") as f:
s = re.sub(r'\s+', ' ', f.read().decode('WINDOWS-1251'), flags=re.M)
for s in re.split(r'(?<=[.!?…]) ', s):
print(s)
import base64, re
def enc(telstr):
s = re.sub(r'\D', '', telstr)
if len(s) < 10 or len(s) == 11 and s[0] not in '78' or len(s) > 11:
raise ValueError('"%s" не похоже на телефонный номер' % telstr)
x, l = int(s[-10:]), bytearray(b'\0\0\0\0\0')
for i in range(4, -1, -1):
x, rest = divmod(x, 256)
l[i] = rest
return base64.encodebytes(l)[:7].decode('utf-8')
def dec(b64):
x = 0
for b in base64.decodebytes(b64.encode('utf-8') + b'=\n'):
x = x * 256 + b
return x
s = enc('8(926)123-4567')
print(s) # AigDOYc
print(dec(s)) # 9261234567