- 假设我们要加密一段字母: huan ying ni 。 秘钥是hello
- 1,首先制作字母表
- 写一排字母(大小写通用),下一行写上对应的数字 从0到25
- 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 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
- 2,将待加密的明文huan ying ni转换成数字
- 如 huan ying ni 。 转换之后是
- h u a n y i n g n i
- 7 20 0 13 24 8 13 6 13 8
- 3,将秘钥hello转换成数字并循环显示,重复位数和明文位数一样,如明文为10位,则密文也是10位
- h e l l o h e l l o
- 7 4 11 11 14 7 4 11 11 14
- 4, 将明文和秘钥按位数相加,注意空格要留空,标点符号不需要转换,直接写在密文相应位置
- 14 24 11 24 38 15 17 17 24 22
- 5,多于25的数字减去25
- 14 24 11 24 13 15 17 17 24 22
- 6,参照密码表,转换成字母密文为
- o y l y n p r r y w
- 7,因此huan ying ni 。的密文是
- oylz nprr yw。
- 秘钥为hello
- ---------------------------------------------------------
- 解密过程
- 1,将密文 oylz nprr yw。 转换成数字
- 14 24 11 24 13 15 17 17 25 22
- 2, 将秘钥hello转换为数字,循环重复,和明文一致
- h e l l o h e l l o
- 7 4 11 11 14 7 4 11 11 14
- 3,密文减去秘钥
- 7 20 0 13 -1 8 13 6 14 8
- 4,如果出现负数就加上25
- 7 20 0 13 24 8 13 6 13 8
- 5,转换成明文字母
- h u a n y i n g n i
- 6,整理得到
- huan ying ni
- 秘钥:hello
Re: Virginia
From Chartreuse Kitten, 1 Year ago, written in Plain Text, viewed 124 times.
This paste is a reply to Virginia from 苏江波
- view diff
URL https://pastebin.vip/view/0dcf5bcd
Embed
— Expand Paste to full width of browser