美文网首页密码
习题6:破解摩斯密码

习题6:破解摩斯密码

作者: 今年说话算话 | 来源:发表于2017-02-21 18:46 被阅读37次
The Morse code encodes every character as a sequence of "dots" and "dashes". For example, the letter A is coded as ·−, letter Q is coded as −−·−, and digit 1 is coded as ·−−−. The Morse code is case-insensitive, traditionally capital letters are used. When the message is written in Morse code, a single space is used to separate the character codes and 3 spaces are used to separate words. For example, the message HEY JUDE in Morse code is ···· · −·−− ·−−− ··− −·· ·.

NOTE: Extra spaces before or after the code have no meaning and should be ignored.

In addition to letters, digits and some punctuation, there are some special service codes, the most notorious of those is the international distress signal SOS (that was first issued by Titanic), that is coded as ···−−−···. These special codes are treated as single special characters, and usually are transmitted as separate words.

def decodeMorse(morseCode):
# ToDo: Accept dots, dashes and spaces, return human-readable message
MORSE_CODE = {'.-': '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',
'...---...': 'sos',
'.-.-.-': '.',
'-.-.--': '!'}
content = ''
word_list = morseCode.split(' ')
for word in word_list:
s = ''
for alpha in word.split():
s += MORSE_CODE[alpha]
content += ' ' + s
return content.strip().upper()

相关文章

  • 习题6:破解摩斯密码

    def decodeMorse(morseCode):# ToDo: Accept dots, dashes an...

  • 蓝鲸安全CTF打卡第一期密码学WriteUp

    检查符号 题目 知识点 摩斯密码、替换密码 解题 这道题很容易就可以看出是摩斯密码摩斯密码就是由'.'和'-'组成...

  • 密码大探究(中)

    上次大家了解到了密码以及摩斯密码的用法。 这次还有一个比摩斯密码还要古老的密码,它就是——凯撒密码...

  • 买买买的底气

    福尔摩斯探案集中有一个故事叫《跳舞的人》,福尔摩斯以字母在英文中出现的频率为突破口,破解了一个用跳舞小人书写的密码...

  • rar密码破解,excel密码破解,zip密码破解

    rar密码破解,详细教程 excel密码破解,详细教程 zip密码破解,详细教程 转自猫密网

  • ​黑客破解工具Hydra在线爆破密码

    ​黑客破解工具Hydra在线爆破密码 这款暴力密码破解工具相当强大,支持几乎所有协议的在线密码破解,其密码能否被破...

  • 摩斯密码

    最近刷了一部电影《风声》,暂不论故事情节,其中有个摩斯密码,甚是感兴趣。 那一起来简单认识吧! 那什么是摩斯密码呢...

  • 摩斯密码

    1 - — — — —滴答答答答 2 - - — — —滴滴答答答 3 - - - — —滴滴滴答答 4 - - ...

  • 摩斯密码

    摩斯密码是一种数字、字母、符号组合的神奇密码,曾广泛用于战争和生活,随着现代化科技的进步,摩斯密码淡出我们的视线。...

  • 摩斯密码( …… )

    哒哒哒哒 这是青春的心跳 也是 一种专属的爱情密码 在你经过那时 急促地胡乱敲打难以启齿的情话 透过低垂的眼眸 一...

网友评论

本文标题:习题6:破解摩斯密码

本文链接:https://www.haomeiwen.com/subject/hhpuwttx.html