This repository was archived by the owner on Jul 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcryptbuddy.py
116 lines (63 loc) · 2.48 KB
/
cryptbuddy.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import os
import time
import sys
from cfonts import render
from termcolor import colored
banner = render("crypt buddy", colors=['blue', 'yellow'], align='center')
print(banner)
print('Warning: This tool is only a testing version.It performs only simple encryption...')
print("======================================================")
sos='Sources:-> github , stackoverflow'
print(colored(sos,'blue'))
cred='Coded and resembled by:--> @$um1t'
print(colored(cred,'yellow'))
lang='Made with love by Python'
print(colored(lang,'green'))
print("======================================================")
# encrypt and decrypt a text using a simple algorithm of offsetting the letters
key = 'abcdefghijklmnopqrstuvwxyz'
def encrypt(n, plaintext):
"""Encrypt the string and return the ciphertext"""
result = ''
for l in plaintext.lower():
try:
i = (key.index(l) + n) % 26
result += key[i]
except ValueError:
result += l
return result.lower()
def decrypt(n, ciphertext):
"""Decrypt the string and return the plaintext"""
result = ''
for l in ciphertext:
try:
i = (key.index(l) - n) % 26
result += key[i]
except ValueError:
result += l
return result
time.sleep(1)
text = str(input(colored('[*] Enter a text or sentence to encrypt:--> ','green')))
offset = 5
time.sleep(1)
print("Loading:")
#animation = ["10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"]
animation = ["[■□□□□□□□□□]","[■■□□□□□□□□]", "[■■■□□□□□□□]", "[■■■■□□□□□□]", "[■■■■■□□□□□]", "[■■■■■■□□□□]", "[■■■■■■■□□□]", "[■■■■■■■■□□]", "[■■■■■■■■■□]", "[■■■■■■■■■■]"]
for i in range(len(animation)):
time.sleep(0.3)
sys.stdout.write("\r" + animation[i % len(animation)])
sys.stdout.flush()
print("\n")
encrypted = encrypt(offset, text)
out='[+] your encrypted text is here:--> '
print(colored(out,'green'),encrypted)
time.sleep(1)
output = render('Thankyou!', colors=['yellow', 'red'], align='center')
print(output)
def restart_program():
python = sys.executable
os.execl(python, python, * sys.argv)
if __name__ == "__main__":
answer = input("\n [-] Do you want to restart this program ?(y/n) ")
if answer.lower().strip() in "y".split():
restart_program()