FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-3/exercises/atbash-cipher/example.py at master · MaxCodeXTC/python-3 · GitHub
MaxCodeXTC
python-3
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-3
/
exercises
/
atbash-cipher
/
example.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
25 lines (16 loc) · 527 Bytes
Breadcrumbs
python-3
/
exercises
/
atbash-cipher
/
example.py
Copy path
File metadata and controls
25 lines (16 loc) · 527 Bytes
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
from
string
import
ascii_lowercase
import
sys
if
sys
.
version_info
[
0
]
==
2
:
from
string
import
maketrans
else
:
maketrans
=
str
.
maketrans
BLKSZ
=
5
trtbl
=
maketrans
(
ascii_lowercase
,
ascii_lowercase
[::
-
1
])
def
base_trans
(
text
):
return
''
.
join
([
c
for
c
in
text
if
c
.
isalnum
()]).
lower
().
translate
(
trtbl
)
def
encode
(
plain
):
cipher
=
base_trans
(
plain
)
return
" "
.
join
([
cipher
[
i
:
i
+
BLKSZ
]
for
i
in
range
(
0
,
len
(
cipher
),
BLKSZ
)])
def
decode
(
ciphered
):
return
base_trans
(
ciphered
)
Back
|
FazBrowse Home
|
New Git URL