easy_morse的题目及附件

This commit is contained in:
2023-09-03 20:01:42 +08:00
parent 86661983c6
commit ec096034ca
3 changed files with 25 additions and 0 deletions

View File

@@ -0,0 +1 @@
./.-/...../-.--/.----/--/-----/.-./....././.----/-.-./-----/-.././

View File

@@ -0,0 +1,23 @@
# 莫斯电码映射
MORSE_CODE_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': '--..',
'0': '-----', '1': '.----', '2': '..---', '3': '...--', '4': '....-', '5': '.....',
'6': '-....', '7': '--...', '8': '---..', '9': '----.',
}
def text_to_morse(text):
morse = ''
for char in text.upper():
morse += MORSE_CODE_DICT.get(char, '') + '/' # 如果字符不在字典中,就跳过
return morse
# 读取文件并进行莫斯编码
with open('flag.txt', 'r') as file:
content = file.read()
morse_code = text_to_morse(content)
with open('cipher.txt', 'w') as f:
f.write(morse_code)

View File

@@ -0,0 +1 @@
EA5Y1M0R5E1C0DE