BUUCTF-摩丝
BUUCTF-摩丝
dict = {
'.-': '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','.----': '1','..---': '2','...--': '3','....-': '4',
'.....': '5','-....': '6','--...': '7','---..': '8','----.': '9',
'-----': '0','..--..': '?','-..-.': '/','-.--.-': '()','-....-': '-',
'.-.-.-': '.'};
# 摩斯码转字符串
def decipherForMos():
a =input("input the string:")
s = a.split(" ") #按空格将输入的字符切片
for item in s:
print(dict[item],end='')
# 字符串转摩斯码
def decipherForStr():
a = input("input the string:")
s =list(a)
for t in s:
for k,v in dict.items():
if v==t:
print(k,end=' ')
if __name__ == '__main__':
decipherForStr()
flag{ILOVEYOU}