-
Notifications
You must be signed in to change notification settings - Fork 0
/
b2e.py
22 lines (22 loc) · 1.03 KB
/
b2e.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import math, random, string
def b2eRandint(seed):
result=int(int(str(math.sqrt(seed)*int(seed)**5).replace(".","").replace("e+","").replace("0",""))**(6*int(str(seed)[:2])))
return(result)
class b2e():
def encode(public_key, text:str):
finaltxt,key="",""
for i in range(len(public_key)):key+=str(ord(str(public_key)[i]))
key,text=str(b2eRandint(int(key))),list(text)
for i in range(int(int(str(key)[10])+5)):text.insert(int(int(str(key)[i+30])),str(chr(705)))
for i in range(len(text)):text[i]=str(int(ord(text[i]))+(int(str(key)[i])+int(str(key)[-5-i])**2))
for i in range(len(text)):finaltxt+=chr(int(text[i]))
return(finaltxt)
def decode(public_key, text:str):
finaltxt,key="",""
for i in range(len(public_key)):key+=str(ord(str(public_key)[i]))
key,text=str(b2eRandint(int(key))),list(text)
for i in range(len(text)):text[i]=str(int(ord(text[i]))-(int(str(key)[i])+int(str(key)[-5-i])**2))
for i in range(len(text)):
try:finaltxt+=chr(int(text[i]))
except Exception as e:break
return(finaltxt.replace(chr(705),""))