n=int(input()) if n >0: b=bin(n)[2:] list_b = [0] * (8 - len(b)) list_b=list_b+list(map(int,b)) str_b="".join('%d'%i for i in list_b) print(str_b) elif n<0: b=bin(n)[3:] list_b=[1]*(8-len(b)) list_b=list_b+list(map(lambda x: (int(x) + 1) % 2, b)) str_b = "".join('%d' % i for i in list_b) int_b=int(str_b,base=2)+1 ans=bin(int_b)[2:] print(ans) else: print("0"*8)
base加密
代码作用: 读取1.txt中需要加密的明文 输出经过base64加密后的密文到2.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# -*- coding:utf-8 -*- import random from base64 import *
process = { '16': lambda x: b16encode(x), '32': lambda x: b32encode(x), '64': lambda x: b64encode(x), } s = "" withopen('1.txt', 'r', encoding='UTF-8') as f: # 读取需要编码的内容 s = "".join(f.readlines()).encode('utf-8')
for i inrange(random.randint(10, 20)): # 随机循环 s = process[random.choice(['16', '32', '64'])](s) # 随机编码
withopen('2.txt', 'w', encoding='UTF-8') as f: # 保存编码后的结果 f.write(str(s, 'utf-8'))
import string import hashlib a='s3c{P7?Y0OG?0XPC?ZPK}' b='b235????f2da???874???63007?4b897' dic1=string.digits+string.ascii_lowercase+string.ascii_uppercase for i1 in dic1: for i2 in dic1: for i3 in dic1: bb='s3c{P7'+i1+'Y0OG'+i2+'0XPC'+i3+'ZPK}' aa=hashlib.md5(bb.encode('utf-8')) bbb=aa.hexdigest() if (bbb[:4]=='b235'): print(i1,i2,i3)