-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflag_encoder.py
More file actions
executable file
·69 lines (64 loc) · 1.11 KB
/
flag_encoder.py
File metadata and controls
executable file
·69 lines (64 loc) · 1.11 KB
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
#from flags import *
alpabete = {'A':".-",
'B':"-...",
'C':"-.-.",
'D':"-..",
'E':".",
'F':"..-.",
'G':"--.",
'H':"....",
'I':"..",
'J':".---",
'K':"-.-",
'L':".-..",
'M':"--",
'N':"-.",
'O':"---",
'P':".--.",
'Q':"--.-",
'R':".-.",
'S':"...",
'T':"-",
'U':"..-",
'V':"...-",
'W':".--",
'X':"-..-",
'Y':"-.--",
'Z':"--..",
'0':"-----",
'1':".----",
'2':"..---",
'3':"...--",
'4':"....-",
'5':".....",
'6':"-....",
'7':"--...",
'8':"---..",
'9':"----.",
")":"-.--.-",
"(":"-.--."
}
def str_to_morse(string):
morsecode = []
for char in string.upper():
morsecode.append(alpabete[char].replace('.', '0').replace('-', '1') )
return morsecode
def converter(arraystr):
arrayout1 = []
arrayout2 = []
for ss in arraystr:
if ss[0] == "0":
arrayout1.append(ss)
arrayout2.append(-1)
else:
arrayout1.append('')
arrayout2.append(int(ss, 2))
return arrayout1, arrayout2
flag_3 = "GH19(dec0dem0rs3f1rmw4r3)"
flag = flag_3.upper()
array = str_to_morse(flag)
print("flag len : ", len(flag))
print("flag is : "+ flag)
flagstr, flagint = converter(array)
print("flagstr = ", flagstr)
print("flagint = ", flagint)