莫尔斯电码对照表_使用莫尔斯电码编码纯文本

莫尔斯电码对照表

This began as a thought experiment while waiting for patches to install on my system.

这是在等待补丁程序安装到我的系统上时进行的一次思想实验。

The Morse Code is an effective means with which to change ASCII data into binary bits. We assume that a "dot" is a zero and a "dash" is a one. Translating an ASCII character into its binary value is accomplished with a lookup table.

莫尔斯电码是将ASCII数据转换为二进制位的有效手段。 我们假设“点”为零,“破折号”为一。 使用查找表可以将ASCII字符转换为二进制值。

It is not enough to convert from ASCII to binary; we must further convert from binary into hexadecimal. This reduces the length of the encoded string, and effectively hides the content of the original plaintext.

从ASCII转换为二进制是不够的。 我们必须进一步从二进制转换为十六进制。 这减少了编码字符串的长度,并有效地隐藏了原始明文的内容。

This is still not enough. We need a means of converting from a string of hexadecimal digits back to the original plaintext. This adds overhead to the final encoded string, but experience has shown this makes the encoding that much more formidable.

这还不够。 我们需要一种将十六进制数字字符串转换回原始明文的方法。 这增加了最终编码字符串的开销,但是经验表明,这使编码更加困难。

We could have used SHA-1 and AES for true encryption, but that would be overkill.

我们本来可以使用SHA-1和AES进行真正的加密,但是那太过分了。

I am the only person I know who uses JavaScript on both the client and the server. All of the script for the Morse Encoder is written in JavaScript, so if you wish to use PHP, Perl or some other server-side language, you will have to translate it from JavaScript.

我是唯一认识到在客户端和服务器上都使用JavaScript的人。 Morse编码器的所有脚本都是用JavaScript编写的,因此,如果您希望使用PHP,Perl或其他服务器端语言,则必须从JavaScript进行翻译。

1.工作原理 (1. How It Works)

本次讨论使用了我心爱的猫Phoebe的名字作为纯文本。 我们从编码过程的结果开始。

It may seem odd to start with an encoded string, but this allows us to explain how we arrived at a given point. The complete code is included, but we will refrain from showing code during this segment.

以编码字符串开头似乎很奇怪,但这使我们能够解释如何到达给定点。 完整的代码已包括在内,但在此部分中我们将避免显示代码。

Morse Encoding "Phoebe" results in:

Morse编码“ Phoebe”导致:

DF 49 CE 69 68 06 E4 88 25 D0

DF 49 CE 69 68 06 E4 88 25 D0

Phoebe is hiding in there, but she is not readily visible. Let's find out why.

菲比躲在那儿,但是她不容易被看见。 让我们找出原因。

In order to make the components of the encoding visible, we convert from hexadecimal into binary:

为了使编码的组件可见,我们将十六进制转换为二进制:

11011111010010011100111001101001011010000000011011100100100010000010010111010000

11011111010010011100111001 1010010110 1000000001 1011100100 1000100000 1001011101 0000

While we find this beautiful, it hard to fathom. Let's add some meaning to the (apparent) chaos:

虽然我们发现它很漂亮,但很难理解。 让我们为(表面上的)混乱添加一些含义:

Checksum
|                        Align bytes:7
|                Type    |   Pad each character:0=no
|                   |    |   | LSB Len:6                                                              MSB Len:0
|                   |    |   | |    [------------------------ Plaintext -----------------------]              |
|                   |    |   | |    Len:4      Len:4      Len:3     Len:1     Len:4      Len:1     Align      |
+--------------+    |    |   | |    |   Ucase  |   Lcase  |   Lcase |   Lcase |   Lcase  |   Lcase Padding    |
+---------+    |    |    |   | |    |   |      |   |      |   |     |   |     |   |      |   |     |          |
+----+    |    |    |    |   | |    |   | P    |   | h    |   | o   |   | e   |   | b    |   | e   |          |
|___ |___ |___ |___ |___ |__ | |___ |__ | |___ |__ | |___ |__ | |__ |__ | |   |__ | |__  |__ | |   |______ ___|
1101 1111 0100 1001 1100 111 0 0110 100 1 0110 100 0 0000 011 0 111 001 0 0   100 0 1000 001 0 0   1011101 0000

kkkk kkkk kkkk kkkk tttt aaa p oooo bbb c dddd bbb c dddd bbb c ddd bbb c d   bbb c dddd bbb c d   eeeeeee xxxx

Where:

k ... FCS-16 checksum (4 bytes)
t ... Encryption type (always '1100')
a ... # pad bytes (the number of binary digits must be a multiple of 4; this is the number of padding bits to ensure this)
p ... Pad each character (0 = no, 1 = yes) *** This example does not pad the individual characters ***
o ... Plaintext length (LSB)
b ... Length of encoded character
c ... Case (0 = lowercase, 1 = UPPERCASE)
d ... Binary-encoded Morse code character (optionally padded to 7 chars)
e ... Word boundary pad chars
x ... Plaintext length (MSB)

Combining all of the binary digits yields our binary string, shown here in 4-bit chunks:

组合所有二进制数字将产生我们的二进制字符串,如以下4位块所示:

1101 1111 0100 1001 1100 1110 0110 1001 0110 1000 0000 0110 1110 0100 1000 1000 0010 0101 1101 0000

1101 1111 0100 1001 1100 1110 0110 1001 0110 1000 0000 0110 1110 0100 1000 1000 0010 0101 1101 0000

Further converting this into hexadecimal, we return to the final result:

进一步将其转换为十六进制&#

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
莫尔斯电码是一种常用的电报编码,可以将字母、数字、标点符号等转换为一系列点和横线的组合。如果想要使用Matlab实现莫尔斯电码加密,可以按照以下步骤进行: 1. 定义莫尔斯电码字母表:莫尔斯电码字母表是由点和横线组成的字符编码序列,每个字母、数字、标点符号都有对应的莫尔斯电码。可以在Matlab中定义一个莫尔斯电码字母表的结构体,每个字母、数字、标点符号对应一个字段,字段的值为该字符的莫尔斯电码。 ``` morseCode.alphabets.A = '.-'; morseCode.alphabets.B = '-...'; morseCode.alphabets.C = '-.-.'; morseCode.alphabets.D = '-..'; morseCode.alphabets.E = '.'; morseCode.alphabets.F = '..-.'; morseCode.alphabets.G = '--.'; morseCode.alphabets.H = '....'; morseCode.alphabets.I = '..'; morseCode.alphabets.J = '.---'; morseCode.alphabets.K = '-.-'; morseCode.alphabets.L = '.-..'; morseCode.alphabets.M = '--'; morseCode.alphabets.N = '-.'; morseCode.alphabets.O = '---'; morseCode.alphabets.P = '.--.'; morseCode.alphabets.Q = '--.-'; morseCode.alphabets.R = '.-.'; morseCode.alphabets.S = '...'; morseCode.alphabets.T = '-'; morseCode.alphabets.U = '..-'; morseCode.alphabets.V = '...-'; morseCode.alphabets.W = '.--'; morseCode.alphabets.X = '-..-'; morseCode.alphabets.Y = '-.--'; morseCode.alphabets.Z = '--..'; morseCode.alphabets.zero = '-----'; morseCode.alphabets.one = '.----'; morseCode.alphabets.two = '..---'; morseCode.alphabets.three = '...--'; morseCode.alphabets.four = '....-'; morseCode.alphabets.five = '.....'; morseCode.alphabets.six = '-....'; morseCode.alphabets.seven = '--...'; morseCode.alphabets.eight = '---..'; morseCode.alphabets.nine = '----.'; morseCode.alphabets.period = '.-.-.-'; morseCode.alphabets.comma = '--..--'; morseCode.alphabets.question = '..--..'; morseCode.alphabets.apostrophe = '.----.'; morseCode.alphabets.exclamation = '-.-.--'; ``` 2. 编写加密函数:加密函数的输入为需要加密的文本,输出为莫尔斯电码序列。可以按照以下思路编写加密函数: - 将需要加密的文本全部转换为大写字母,方便后续处理 - 对于每个字符,查找莫尔斯电码字母表中对应的莫尔斯电码,将莫尔斯电码序列拼接到一起,每个字符之间用空格隔开 ``` function [morseCodeSequence] = encryptMorseCode(text) % Convert all letters to uppercase text = upper(text); % Get the morse code dictionary morseCode = getMorseCodeDictionary(); % Initialize the morse code sequence morseCodeSequence = ''; % Iterate through each character in the text for i=1:length(text) % Get the morse code for the current character if isfield(morseCode.alphabets, text(i)) morseCodeSequence = [morseCodeSequence, morseCode.alphabets.(text(i)), ' ']; elseif text(i)==' ' morseCodeSequence = [morseCodeSequence, '/ ']; end end end ``` 3. 测试加密函数:可以编写一个简单的测试脚本来测试加密函数,例如: ``` text = 'Hello World!'; morseCodeSequence = encryptMorseCode(text); disp(morseCodeSequence); ``` 输出结果为: ``` .... . .-.. .-.. --- / .-- --- .-. .-.. -.. -.-.-- ``` 这就是将原始文本加密后的莫尔斯电码序列。 需要注意的是,莫尔斯电码加密只是一种简单的加密方式,容易被破解。如果需要更加安全的加密方式,可以考虑使用其他加密算法,如AES、RSA等。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值