File tree Expand file tree Collapse file tree 7 files changed +137
-6
lines changed Expand file tree Collapse file tree 7 files changed +137
-6
lines changed Original file line number Diff line number Diff line change
1
+ #PROJECT1
2
+ #CAESAR CIPHER DECODER
3
+
4
+ #Author: InTruder
5
+ #Cloned from: https://github.com/InTruder-Sec/caesar-cipher
6
+
7
+
8
+ def main ():
9
+ print ("[>] CAESAR CIPHER DECODER!!! \n " )
10
+ print ("[1] Encrypt\n [2] Decrypt" )
11
+ try :
12
+ func = int (input ("Choose one of the above(example for encode enter 1): " ))
13
+ except :
14
+ print ("\n [>] Invalid input" )
15
+ exit ()
16
+
17
+ if func == 2 :
18
+ decode ()
19
+ else :
20
+ if func == 1 :
21
+ encode ()
22
+ else :
23
+ print ("\n [>] Invalid input" )
24
+ exit ()
25
+
26
+ def encode ():
27
+ text = input ("Enter text to encode: " )
28
+ key = input ("Enter number of characters you want to shift: " )
29
+ encoded_cipher = ""
30
+ try :
31
+ key = int (key )
32
+ except :
33
+ print ("Only intigers between 0 to 25 are allowed. Try again :)" )
34
+ exit ()
35
+ if key > 25 :
36
+ print ("Only intigers between 0 to 25 are allowed. Try again :)" )
37
+ exit ()
38
+ else :
39
+ key = key
40
+ text = text .upper ()
41
+ for char in text :
42
+ ascii = ord (char )
43
+ if ascii > 90 :
44
+ new_ascii = ascii
45
+ else :
46
+ if ascii < 65 :
47
+ new_ascii = ascii
48
+ else :
49
+ new_ascii = ascii + key
50
+ if new_ascii > 90 :
51
+ new_ascii = new_ascii - 26
52
+ else :
53
+ new_ascii = new_ascii
54
+ encoded = chr (new_ascii )
55
+ encoded_cipher = encoded_cipher + encoded
56
+ print ("Encoded text: " + encoded_cipher )
57
+
58
+
59
+
60
+ def decode ():
61
+ cipher = input ("\n [>] Enter your cipher text: " )
62
+ print ("Posiblities of cipher text are: \n " )
63
+ cipher = cipher .lower ()
64
+ for i in range (1 , 26 ):
65
+ decoded = ""
66
+ decoded_cipher = ""
67
+ for char in cipher :
68
+ ascii = ord (char )
69
+ if ascii < 97 :
70
+ new_ascii = ascii
71
+ else :
72
+ if ascii > 122 :
73
+ new_ascii = ascii
74
+ else :
75
+ new_ascii = ascii - int (i )
76
+ if new_ascii < 97 :
77
+ new_ascii = new_ascii + 26
78
+ else :
79
+ new_ascii = new_ascii
80
+ decoded = chr (new_ascii )
81
+ decoded_cipher = decoded_cipher + decoded
82
+ print ("\n " + decoded_cipher )
83
+
84
+
85
+ if __name__ == '__main__' :
86
+ main ()
Original file line number Diff line number Diff line change
1
+ #pattern
2
+ #1234567
3
+ #123456
4
+ #12345
5
+ #1234
6
+ #123
7
+ #1
8
+
9
+ def main ():
10
+ lines = int (input ("Enter no.of lines: " ))
11
+ pattern (lines )
12
+
13
+ def pattern (lines ):
14
+ m = lines + 1
15
+ l = 1
16
+ for i in reversed (range (lines + 1 )):
17
+ t = ""
18
+ k = 1
19
+ for m in range (i ):
20
+ if k == 10 :
21
+ k = 0
22
+ t = str (t ) + str (k )
23
+ k = k + 1
24
+ print (t )
25
+
26
+ if __name__ == "__main__" :
27
+ main ()
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ #pattern Reverse piramid of numbers
2
+ #1
3
+ #21
4
+ #321
5
+ #4321
6
+ #54321
7
+
8
+ def main ():
9
+ lines = int (input ("Enter number of lines: " ))
10
+ pattern (lines )
11
+
12
+ def pattern (rows ):
13
+
14
+
15
+ for row in range (1 , rows ):
16
+ for column in range (row , 0 , - 1 ):
17
+ print (column , end = ' ' )
18
+ print ("" )
19
+
20
+
21
+
22
+
23
+ if __name__ == "__main__" :
24
+ main ()
File renamed without changes.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments