diff --git a/crypto/easy_morse/cipher.txt b/crypto/easy_morse/cipher.txt new file mode 100644 index 0000000..dfec39a --- /dev/null +++ b/crypto/easy_morse/cipher.txt @@ -0,0 +1 @@ +./.-/...../-.--/.----/--/-----/.-./....././.----/-.-./-----/-.././ \ No newline at end of file diff --git a/crypto/easy_morse/easy_morse.py b/crypto/easy_morse/easy_morse.py new file mode 100644 index 0000000..8a379a7 --- /dev/null +++ b/crypto/easy_morse/easy_morse.py @@ -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) diff --git a/crypto/easy_morse/flag.txt b/crypto/easy_morse/flag.txt new file mode 100644 index 0000000..c8e774a --- /dev/null +++ b/crypto/easy_morse/flag.txt @@ -0,0 +1 @@ +EA5Y1M0R5E1C0DE \ No newline at end of file