-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrypto.py
38 lines (32 loc) · 986 Bytes
/
crypto.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import cipher
# ----------------------encryption---------------------------
def encrypto(word, key):
lst = []
key2 = cipher.enc(key)
# print(key2)
key2 = int(str(int(int(key2)/773))[:len(str(int(key2)))-10:-1])
# print(key2)
for x in word:
# print(lst,end="\n")
A = int(ord(x)) + int(key2)
while A > 126:
A -= 126
lst.append(chr(int(A)))
prin = "".join(lst)
return prin
# -----------------------------------------------------------
# ----------------------decryption---------------------------
def decrypto(word, key):
lst = []
key2 = cipher.enc(key)
key2 = int(str(int(int(key2)/773))[:len(str(int(key2)))-10:-1])
# print(key2)
for x in word:
# print(lst,end="\n")
A = int(ord(x)) - int(key2)
while A < 0:
A += 126
lst.append(chr(int(A)))
rin = "".join(lst)
return rin
# ----------------------------------------------------------