FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Python/EncryptionTool.py at master · txrxcode/Python · GitHub
txrxcode
/
Python
Public
forked from
geekcomputers/Python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Python
/
EncryptionTool.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
100 lines (87 loc) · 2.61 KB
Breadcrumbs
Python
/
EncryptionTool.py
Copy path
File metadata and controls
100 lines (87 loc) · 2.61 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#GGearing
#Simple encryption script for text
#This was one my first versions of this script
#09/07/2017
text
=
input
(
"Enter text: "
)
PI
=
3.14159265358979323846264338327950288419716939937510
text
=
list
(
text
)
values
=
list
()
reverse
=
list
()
def
encryptChar
(
target
):
#encrytion algorithm
target
=
(((
target
+
42
)
*
PI
)
-
449
)
return
target
def
decryptChar
(
target
):
target
=
(((
target
+
449
)
/
PI
)
-
42
)
return
target
def
encrypt
(
input_text
):
input_text_list
=
list
(
input_text
)
col_values
=
list
()
for
i
in
range
(
len
(
input_text_list
)):
current
=
ord
(
input_text_list
[
i
])
current
=
encryptChar
(
current
)
col_values
.
append
(
current
)
return
col_values
def
decrypt
(
enc_text
):
enc_list
for
i
in
range
(
len
(
input_text_list
)):
current
=
int
(
decryptChar
(
values
[
i
]))
current
=
chr
(
current
)
col_values
.
append
(
current
)
return
col_values
def
readAndDecrypt
(
filename
):
file
=
open
(
filename
,
"r"
)
data
=
file
.
read
()
datalist
=
list
()
datalistint
=
list
()
actualdata
=
list
()
datalist
=
data
.
split
(
" "
)
datalist
.
remove
(
''
)
for
i
in
range
(
len
(
datalist
)):
datalistint
.
append
(
float
(
datalist
[
i
]))
for
i
in
range
(
len
(
datalist
)):
current1
=
int
(
decryptChar
(
datalistint
[
i
]))
current1
=
chr
(
current1
)
actualdata
.
append
(
current1
)
return
actualdata
def
readAndEncrypt
(
filename
):
file
=
open
(
filename
,
"r"
)
data
=
file
.
read
()
datalist
=
list
(
data
)
encrypted_list
=
list
()
encrypted_list_str
=
list
()
for
i
in
range
(
len
(
datalist
)):
current
=
ord
(
datalist
[
i
])
current
=
encryptChar
(
current
)
encrypted_list
.
append
(
current
)
return
encrypted_list
def
readAndEncryptAndSave
(
inp_file
,
out_file
):
enc_list
=
readAndEncrypt
(
inp_file
)
output
=
open
(
out_file
,
"w"
)
for
i
in
range
(
len
(
enc_list
)):
output
.
write
(
str
(
enc_list
[
i
])
+
" "
)
output
.
close
()
def
readAndDecryptAndSave
(
inp_file
,
out_file
):
dec_list
=
readAndDecrypt
(
inp_file
)
output
=
open
(
out_file
,
"w"
)
for
i
in
range
(
len
(
dec_list
)):
output
.
write
(
str
(
dec_list
[
i
]))
output
.
close
()
#encryption
for
i
in
range
(
len
(
text
)):
current
=
ord
(
text
[
i
])
current
=
encryptChar
(
current
)
values
.
append
(
current
)
#decryption
for
i
in
range
(
len
(
text
)):
current
=
int
(
decryptChar
(
values
[
i
]))
current
=
chr
(
current
)
reverse
.
append
(
current
)
print
(
reverse
)
#saves encrypted in txt file
output
=
open
(
"encrypted.txt"
,
"w"
)
for
i
in
range
(
len
(
values
)):
output
.
write
(
str
(
values
[
i
])
+
" "
)
output
.
close
()
#read and decrypts
print
(
readAndDecrypt
(
"encrypted.txt"
))
Back
|
FazBrowse Home
|
New Git URL