easy_morse的题目及附件
This commit is contained in:
1
crypto/easy_morse/cipher.txt
Normal file
1
crypto/easy_morse/cipher.txt
Normal file
@@ -0,0 +1 @@
|
||||
./.-/...../-.--/.----/--/-----/.-./....././.----/-.-./-----/-.././
|
23
crypto/easy_morse/easy_morse.py
Normal file
23
crypto/easy_morse/easy_morse.py
Normal 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)
|
1
crypto/easy_morse/flag.txt
Normal file
1
crypto/easy_morse/flag.txt
Normal file
@@ -0,0 +1 @@
|
||||
EA5Y1M0R5E1C0DE
|
Reference in New Issue
Block a user