-
Notifications
You must be signed in to change notification settings - Fork 0
/
transposition_keycipher
executable file
·37 lines (28 loc) · 1.26 KB
/
transposition_keycipher
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
#!/bin/env python3
##########################################################################
### aleph ###
###--------------------------------------------------------------------###
### Description ###
### ###
### Simple script in order to apply the transposition cipher ###
### with key ###
### ###
###--------------------------------------------------------------------###
### ###
##########################################################################
import re
key = input("[>] Select a number for the key (0-99) : ")
if not re.match("^[0-9]{1,2}$",key):
print("[x] ERROR: WRONG VALUE")
exit(1)
key = int(key)
plaintext = input("[>] Write the text to cipher: ")
plaintext = re.sub("[,. ¿?!¡]","",plaintext)
cipher=""
lenght = len(plaintext)
for iter in range(key):
sentinel = iter
while sentinel < lenght:
cipher = cipher + plaintext[sentinel]
sentinel += key
print(cipher)