Skip to content

Commit 41fc21d

Browse files
committed
Initial commit
0 parents  commit 41fc21d

12 files changed

+238
-0
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
1.04 KB
Binary file not shown.
1.01 KB
Binary file not shown.

__pycache__/test.cpython-39.pyc

1.28 KB
Binary file not shown.

cripto.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
from tkinter import *
2+
from tkinter import Text
3+
from criptofunction import cipher
4+
from PIL import ImageTk,Image
5+
import string
6+
7+
#main window
8+
root = Tk()
9+
root.title("Cripto")
10+
root.iconbitmap('photos/criptologo.ico')
11+
root.geometry("750x450")
12+
root.minsize(300, 200)
13+
root.configure(background='#215153')
14+
15+
#functions for code and decode
16+
def startcode():
17+
decode.delete('1.0','end')
18+
decode.insert('1.0', cipher(code.get('1.0',END),key.get(),'c'))
19+
return
20+
21+
def startdecode():
22+
code.delete('1.0','end')
23+
code.insert('1.0', cipher(decode.get('1.0',END),key.get(),'d'))
24+
return
25+
26+
27+
#title
28+
p_title=Label(root,text="\nWelcome to Cripto 1.0\n\nWith this program you can code your messages and decode it! Try it with your friends!\n")
29+
p_title.configure(background='#4d5753',foreground='#96cdc9')
30+
31+
32+
p_title.place(relx=0.5,rely=0,anchor='n',relheight=0.15,relwidth=1.0)
33+
34+
#text labels
35+
p_t1=Label(root,text='DECODED')
36+
p_t2=Label(root,text='CODED')
37+
p_t1.configure(background='#215153',foreground='#96cdc9')
38+
p_t2.configure(background='#215153',foreground='#96cdc9')
39+
40+
p_t1.place(relx=0.25,rely=0.175,anchor='n')
41+
p_t2.place(relx=0.75,rely=0.175,anchor='n')
42+
43+
#text boxes
44+
code=Text(root,width=50,background='#4d5753',foreground='#96cdc9')
45+
decode=Text(root,width=50,background='#4d5753',foreground='#96cdc9')
46+
47+
code.place(relx=0.25,rely=0.25,anchor='n',relwidth=0.4,relheight=0.4)
48+
decode.place(relx=0.75,rely=0.25,anchor='n',relwidth=0.4,relheight=0.4)
49+
50+
#code & decode button
51+
start1=Button(root,text='CODE',padx=10,pady=10,command=startcode)
52+
start2=Button(root,text='DECODE',padx=10,pady=10,command=startdecode)
53+
start1.configure(background='#588e84',activebackground='#54958a',borderwidth=0)
54+
start2.configure(background='#588e84',activebackground='#54958a',borderwidth=0)
55+
56+
start1.place(relx=0.25,rely=0.7,anchor='n',relheight=0.1,relwidth=0.1)
57+
start2.place(relx=0.75,rely=0.7,anchor='n',relheight=0.1,relwidth=0.1)
58+
59+
#key component
60+
key=Entry(root,width=50,background='#4d5753',foreground='#96cdc9')
61+
key.place(relx=0.5,rely=0.9,anchor='n',relwidth=0.4)
62+
63+
key.insert(0,'Type your cripto key here')
64+
65+
#random photo
66+
img1=ImageTk.PhotoImage(Image.open('photos/criptologo2.png'))
67+
lab1_=Label(image=img1)
68+
lab1_.place(relx=0,rely=0,anchor='nw',relheight=0.15,relwidth=0.15)
69+
70+
root.mainloop()

cripto_chars.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--->The more scrambled the chars the better!
2+
--->Cripto will only codify the chars that are in this list!
3+
--->Your can use other chars but they will remain the same!
4+
--->Please on the line bellow insert the chars that you want to use: (OBS:'space' is a char)
5+
lxboGtjM1DnamE3KczN7Zi4qTXWeu9 CdIVLF58fAgsHQB2OJyhR0wvrkpPUYS6!;:}>$#_%)[&<~.",@*^-=+({?`]
6+
--->On the line bellow insert the formula you want to use to code it: (OBS:Caution may break program!, use "default" for baked in formula)
7+
default
8+
--->End of file

criptofunction.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
def cipher(msg,key,op):
2+
3+
#getting chars
4+
with open ("cripto_chars.txt", "r") as myfile:
5+
file_r = myfile.readlines()[4]
6+
file_find = file_r.find(' ')
7+
file_r2 = file_r.split()
8+
chars = ' '.join(file_r2)
9+
chars_n = int(len(chars) - 1)
10+
11+
#getting equation
12+
with open ("cripto_chars.txt", "r") as myfile:
13+
eq_e = myfile.readlines()[6]
14+
eq_e2 = eq_e.split()
15+
eq_e = ''.join(eq_e2)
16+
17+
#coded msg var
18+
code_msg = ''
19+
20+
#key
21+
if type(key) == int or type(key) == float:
22+
key = int(key)
23+
else:
24+
key,key1 = str(key),0
25+
for i in key:
26+
key1 = key1+ord(i)
27+
key = key1
28+
while key>100:
29+
key= int(key/10)
30+
lis = [key]*(len(msg)+1)
31+
for i in range(1,len(lis)):
32+
if eq_e == 'default':
33+
if lis[i-2]%2==0:
34+
lis[i] = 1+sum(lis[i-2:i])
35+
if lis[i-2]%2!=0:
36+
lis[i] = int(lis[i-2]/5)
37+
else:
38+
eq = lambda x: eval(eq_e)
39+
lis[i] = eq(lis[i-1])
40+
lis = lis[1:]
41+
42+
#Function
43+
for i in range(len(msg)):
44+
#function for coding
45+
if op == 'c':
46+
if msg[i] in chars:
47+
code_msg += chars[int((chars.find(msg[i]) - lis[i])%chars_n)]
48+
else:
49+
code_msg += msg[i]
50+
#Function for decoding
51+
if op == 'd':
52+
if msg[i] in chars:
53+
code_msg += chars[int((chars.find(msg[i]) + lis[i])%chars_n)]
54+
else:
55+
code_msg += msg[i]
56+
return code_msg

criptofunction_1.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
def cipher(message,key,tip):
2+
3+
#getting chaars
4+
with open ("cripto_chars.txt", "r") as myfile:
5+
b = myfile.readlines()[4]
6+
d = b.find(' ')
7+
b1 = b.split()
8+
alfab = ' '.join(b1)
9+
alfab_n = int(len(alfab) - 1)
10+
11+
#msg var
12+
newmsg = ''
13+
14+
#key
15+
if type(key) == int or type(key) == float:
16+
key = int(key)
17+
else:
18+
key,key1 = str(key),0
19+
for i in key:
20+
key1 = key1+ord(i)
21+
key = key1
22+
while key>100:
23+
key= int(key/10)
24+
lis = [key]*(len(message)+1)
25+
for i in range(1,len(lis)):
26+
if lis[i-2]%2==0:
27+
lis[i] = 1+sum(lis[i-2:i])
28+
if lis[i-2]%2!=0:
29+
lis[i] = int(lis[i-2]/5)
30+
lis = lis[1:]
31+
32+
#Function
33+
for i in range(len(message)):
34+
#function for coding
35+
if tip == 'c':
36+
if message[i] in alfab:
37+
newmsg += alfab[int((alfab.find(message[i]) - lis[i])%alfab_n)]
38+
else:
39+
newmsg += message[i]
40+
#Function for decoding
41+
if tip == 'd':
42+
if message[i] in alfab:
43+
newmsg += alfab[int((alfab.find(message[i]) + lis[i])%alfab_n)]
44+
else:
45+
newmsg += message[i]
46+
return newmsg

photos/criptologo.ico

93.7 KB
Binary file not shown.

photos/criptologo.png

36.5 KB
Loading

photos/criptologo2.png

14.6 KB
Loading

test.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
def cipher(msg,key,op):
2+
3+
#getting chars
4+
with open ("cripto_chars.txt", "r") as myfile:
5+
file_r = myfile.readlines()[4]
6+
file_find = file_r.find(' ')
7+
file_r2 = file_r.split()
8+
chars = ' '.join(file_r2)
9+
chars_n = int(len(chars) - 1)
10+
11+
#getting equation
12+
with open ("cripto_chars.txt", "r") as myfile:
13+
eq_e = myfile.readlines()[6]
14+
eq_e2 = eq_e.split()
15+
eq_e = ''.join(eq_e2)
16+
17+
#coded msg var
18+
code_msg = ''
19+
20+
#key
21+
if type(key) == int or type(key) == float:
22+
key = int(key)
23+
else:
24+
key,key1 = str(key),0
25+
for i in key:
26+
key1 = key1+ord(i)
27+
key = key1
28+
while key>100:
29+
key= int(key/10)
30+
lis = [key]*(len(msg)+1)
31+
for i in range(1,len(lis)):
32+
if eq_e == 'default':
33+
if lis[i-2]%2==0:
34+
lis[i] = 1+sum(lis[i-2:i])
35+
if lis[i-2]%2!=0:
36+
lis[i] = int(lis[i-2]/5)
37+
else:
38+
eq = lambda x: eval(eq_e)
39+
lis[i] = eq(lis[i-1])
40+
lis = lis[1:]
41+
42+
#Function
43+
for i in range(len(msg)):
44+
#function for coding
45+
if op == 'c':
46+
if msg[i] in chars:
47+
code_msg += chars[int((chars.find(msg[i]) - lis[i])%chars_n)]
48+
else:
49+
code_msg += msg[i]
50+
#Function for decoding
51+
if op == 'd':
52+
if msg[i] in chars:
53+
code_msg += chars[int((chars.find(msg[i]) + lis[i])%chars_n)]
54+
else:
55+
code_msg += msg[i]
56+
return code_msg

0 commit comments

Comments
 (0)