Skip to content

Instantly share code, notes, and snippets.

@huangzizhu
Created February 3, 2023 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huangzizhu/46b69394d8c5f87b05ab1c089330246d to your computer and use it in GitHub Desktop.
Save huangzizhu/46b69394d8c5f87b05ab1c089330246d to your computer and use it in GitHub Desktop.
初始样(垃圾)
import random
import re
str1 = ' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
str2 = '~!@#$%^&*()_+`-={}|[]:;<>,.?/'
str3 = "'"
str4 = '"'
string = str1 + str2 + str3 + str4
lst = list(string)
class Code:
def encode_0b(string):
return ' '.join([bin(ord(c)).replace('0b', '') for c in string])
def decode_ob(string):
return ''.join([chr(i) for i in [int(b, 2) for b in string.split(' ')]])
class Secret:
class Encrypt:
def _encrypt_(lstn, lst_secret):
lst_res = []
for n in lstn:
for x, y in zip(lst, lst_secret):
if n == x:
lst_res.append(y)
res_str = ''.join(lst_res)
return res_str
def randomencrypt(string):
lstn = list(string)
lst_res = []
random_lst = random.sample(lst, 94)
lst_number = []
for item in random_lst:
i = lst.index(item)
lst_number.append(i)
for i1 in lst_number:
n = lst_number.index(i1)
if i1 in range(0, 10):
lst_number[n] = '0' + str(i1)
else:
lst_number[n] = str(i1)
str_num = ''.join(lst_number)
str0b = Code.encode_0b(str_num)
str0b = str0b.replace(' ', '')
str_1 = ''
for x, y in zip([9, 8, 7, 6, 5, 4, 3, 2], ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']):
for i in range(1, x + 1):
str_1 = str_1 + '1'
str0b = str0b.replace(str_1, y)
str_1 = ''
for x, y in zip([9, 8, 7, 6, 5, 4, 3, 2], ['I', 'J', 'K', 'L', 'M', 'N', 'O', 'P']):
for i in range(1, x + 1):
str_1 = str_1 + '0'
str0b = str0b.replace(str_1, y)
str_1 = ''
str0b = str0b.replace('10', 'Q')
str0b = str0b.replace('01', 'R')
key = str0b
for n in lstn:
for x, y in zip(lst, random_lst):
if n == x:
lst_res.append(y)
res_str = ''.join(lst_res)
return [res_str, key]
def encrypt1(string):
lst_secret1 = ['G', 'w', 'O', 'l', 'm', 'S', 'c', '6', '-', 'J', 'N', 'W', 'v', 'k', 'H', 'F', '[', '?',
'>', 't', 'f', '&', ';', 'x', 'u', 's', '3', 'p', 'I', 'K', '#', '$', 'h', 'C', '7', '4',
'U', '.', '0', 'i', '_', '}', '*', '8', '%', '~', 'z', ':', 'T', ',', '5', "'", 'e', 'n',
'2', '{', 'P', 'j', 'q', '^', '+', 'D', '!', 'Q', 'B', 'R', 'V', '/', 'y', ']', '|', 'Z',
'M', 'L', '<', '9', 'd', '=', '1', 'r', '(', 'g', '@', ' ', 'b', 'a', 'A', 'E', '`', ')',
'X', '"', 'Y', 'o']
lstn = list(string)
res_str = Secret.Encrypt._encrypt_(lstn, lst_secret1)
return res_str
class Decrypt:
def _decrtpt_(lstn, lst_secret):
lst_res = []
for n in lstn:
for x, y in zip(lst_secret, lst):
if n == x:
lst_res.append(y)
res_str = ''.join(lst_res)
return res_str
def cache(key):
key = key.replace('R', '01')
key = key.replace('Q', '10')
str_1 = ''
for x, y in zip([9, 8, 7, 6, 5, 4, 3, 2], ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']):
for i in range(1, x + 1):
str_1 = str_1 + '1'
key = key.replace(y, str_1)
str_1 = ''
for x, y in zip([9, 8, 7, 6, 5, 4, 3, 2], ['I', 'J', 'K', 'L', 'M', 'N', 'O', 'P']):
for i in range(1, x + 1):
str_1 = str_1 + '0'
key = key.replace(y, str_1)
str_1 = ''
key = re.findall(".{6}", key)
key = " ".join(key)
key = Code.decode_ob(key)
key = re.findall(".{2}", key)
for i1 in ['01', '02', '03', '04', '05', '06', '07', '08', '09']:
n = key.index(i1)
i1.replace('0', '')
i1 = int(i1)
key[n] = i1
n = key.index('00')
key[n] = 0
for i in key:
n = key.index(i)
key[n] = int(i)
lst_random = []
for i in key:
n = lst[i]
lst_random.append(n)
return lst_random
def randomdecrypt(string, key):
key = key.replace('R', '01')
key = key.replace('Q', '10')
str_1 = ''
for x, y in zip([9, 8, 7, 6, 5, 4, 3, 2], ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']):
for i in range(1, x + 1):
str_1 = str_1 + '1'
key = key.replace(y, str_1)
str_1 = ''
for x, y in zip([9, 8, 7, 6, 5, 4, 3, 2], ['I', 'J', 'K', 'L', 'M', 'N', 'O', 'P']):
for i in range(1, x + 1):
str_1 = str_1 + '0'
key = key.replace(y, str_1)
str_1 = ''
key = re.findall(".{6}", key)
key = " ".join(key)
key = Code.decode_ob(key)
key = re.findall(".{2}", key)
for i1 in ['01', '02', '03', '04', '05', '06', '07', '08', '09']:
n = key.index(i1)
i1.replace('0', '')
i1 = int(i1)
key[n] = i1
n = key.index('00')
key[n] = 0
for i in key:
n = key.index(i)
key[n] = int(i)
lst_random = []
for i in key:
n = lst[i]
lst_random.append(n)
lstn = list(string)
str_res = Secret.Decrypt._decrtpt_(lstn, lst_random)
return str_res
def decrypt1(string):
lst_secret1 = ['G', 'w', 'O', 'l', 'm', 'S', 'c', '6', '-', 'J', 'N', 'W', 'v', 'k', 'H', 'F', '[', '?',
'>', 't', 'f', '&', ';', 'x', 'u', 's', '3', 'p', 'I', 'K', '#', '$', 'h', 'C', '7', '4',
'U', '.', '0', 'i', '_', '}', '*', '8', '%', '~', 'z', ':', 'T', ',', '5', "'", 'e', 'n',
'2', '{', 'P', 'j', 'q', '^', '+', 'D', '!', 'Q', 'B', 'R', 'V', '/', 'y', ']', '|', 'Z',
'M', 'L', '<', '9', 'd', '=', '1', 'r', '(', 'g', '@', ' ', 'b', 'a', 'A', 'E', '`', ')',
'X', '"', 'Y', 'o']
lstn = list(string)
res_str = Secret.Decrypt._decrtpt_(lstn, lst_secret1)
return res_str
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment