File tree 2 files changed +43
-0
lines changed
2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Scytale Cipher
2
+
3
+ Very basic implementation of the Scytale cipher.
Original file line number Diff line number Diff line change
1
+
2
+ def encrypt (key , plaintext ):
3
+
4
+ grid = []
5
+ row = []
6
+
7
+ for letter in plaintext :
8
+ row .append (letter )
9
+ if len (row ) == key :
10
+ grid .append (row )
11
+ row = []
12
+
13
+ text = []
14
+
15
+ for col in range (key ):
16
+ temp = []
17
+ for row in grid :
18
+ temp .append (row [col ])
19
+ text .append (str .join ('' , temp ))
20
+
21
+ return str .join ('' , text )
22
+
23
+
24
+ def decrypt (key , ciphertext ):
25
+
26
+ rows = len (ciphertext ) // key
27
+ grid = []
28
+
29
+ for row in range (rows ):
30
+ temp_row = []
31
+ for i in range (key ):
32
+ temp_row .append (ciphertext [row + i * rows ])
33
+ grid .append (temp_row )
34
+
35
+ rows = []
36
+
37
+ for i in range (len (grid )):
38
+ rows .append (str .join ('' , grid [i ]))
39
+
40
+ return str .join ('' , rows )
You can’t perform that action at this time.
0 commit comments