当前位置:网站首页>古典密码体制--代换和置换
古典密码体制--代换和置换
2022-06-27 06:01:00 【Da|Sha|Niao】
一、介绍与分类
1.介绍:
古典密码时期一般认为是从古代到19世纪末,这个时期生产力水平低,加密、解密方法主要以纸、笔或简单的器械来实现,在这个时期提出和使用的密码称为古典密码。古典密码是密码学发展的初级阶段。尽管古典密码大都较简单,但由于其安全性差,目前应用很少。研究古典密码的原理,有助于理解、构造和分析近代密码。替代( substitution)和置换(permutation)是古典密码中用到的两种基本处理技巧,它们在现代密码学中也得到了广泛使用。
2.实现技术:
- 代换 将明文字符替换成其他的字母、数字或符号
- 置换 明文的字母相同,但被打乱了
3.分类
- 代换密码
- 单表代换密码
- 多表代换密码
- 置换密码
二、代换密码
1.单表代换密码
(1).移位密码
Ek(P): Ci = (Pi+k) mod n, Dk(P): Pi = (Ci-k) mod n,
其中Ek为加密算法,Pi为明文,Ci为密文,k位密钥,n为字母的个数,Dk为解密算法。
如果是英文字母间的代换,也可以写成以下形式:
Ci = (Pi + k) mod 26 Pi = (Ci - k) mod 26,其中k∈[0,25]
其中凯撒密码Ci = (Pi + 3) mod 26就是一种移位代换密码。
(2).仿射密码
Ek(P) = (aPi + b) mod m
(3).代换密码
指每一个字母都由另一个字母表(从明文字母到密文字母的映射)中的字母加密
破译方法:穷举密钥法、统计分析法(利用语言规律)
2.多表代换密码
(1).维吉尼亚密码
维吉尼亚密码由一些偏移量不同的恺撒密码组成,每一个明文字母的偏移量由一个给定的密钥决定。如明文"abcd"(密钥为plan),则明文字母a的偏移量即为p的位数15。a偏移15位后为p,p即为明文字母对应的密文字母。
Ci = (Pi + ki) mod 26
维吉尼亚密码也看作是依据于一张二维密码表,明文字母和对应的密钥字母分别为行数和列数,在表中找到相应的字母即为密文字母

举例:
明文:howareyou
密钥:mine
| 明文(P) | H | O | W | A | R | E | Y | O | U |
| 密钥(k) | M | I | N | E | M | I | N | E | M |
| 密文(C) | T | W | J | E | D | M | L | S | G |
破译技巧:
- 间隔是密钥长度整数倍的对象代换结果也相同
- 间隔是密钥长度整数倍的位置上的代换是单表代换
(2).一次一密
用随机的非重复的字符集合作为输出密文。一旦使用了变换的输入密文,就不再在任何其他消息中使用这个输入密文(因此是一次性的)。输入密文的长度等于原消息明文的长度。
以下是主要步骤.
1.按递增顺序把每个明文字母作为一个数字,A=0,B=1等等.
2.对输入明文中每一个字母做相同的处理.
3.将明文中的每个字母与密钥中的相应字母相加.
4.如果得到的和大于26,则从中减去26 (mod 26)
5.将和转化为字母,从而得到密文.
三、置换密码
置换密码是⼀种通过⼀定规则改变字符串中字符的顺序从⽽实现加密的密码算法。
与代换密码的区别:
代换密码是将明文字母用不同的密文字母代替,生成的密文中可能有明文未包含的字母,而置换密码是仅仅打乱明文字母的位置和顺序
置换密码有很多种,举例一种:将密文一行一行写在表格中,按一列一列的顺序读取,如明文:howareyouImfinethankyouandyouhaha,则密文:hfuoiawnnaedrtyehoyauonhukaiyhmoa。
| H | O | W | A | R | E | Y | O | U | I | M |
| F | I | N | E | T | H | A | N | K | Y | O |
| U | A | N | D | Y | O | U | H | A | H | A |
边栏推荐
- Netease cloud music params and encseckey parameter generation code
- 多线程基础部分Part 1
- 30个单片机常见问题及解决办法!
- Thinking technology: how to solve the dilemma in work and life?
- 426 binary tree (513. find the value in the lower left corner of the tree, 112. sum of paths, 106. construct a binary tree from the middle order and post order traversal sequence, 654. maximum binary
- 表单校验 v-model 绑定的变量,校验失效的解决方案
- 【Cocos Creator 3.5.1】this. node. Use of getposition (this.\u curpos)
- C# netcore中 配置帮助类IConfiguration
- Multithreading basic part part 1
- 【Cocos Creator 3.5.1】event. Use of getbutton()
猜你喜欢

Thinking technology: how to solve the dilemma in work and life?

427-二叉树(617.合并二叉树、700.二叉搜索树中的搜索、98. 验证二叉搜索树、530.二叉搜索树的最小绝对差)

使用 WordPress快速个人建站指南

Small program of C language practice (consolidate and deepen the understanding of knowledge points)

Altium designer 19 device silk screen label position shall be placed uniformly in batches

多线程基础部分Part3

Free SSH and telnet client putty

JVM object composition and storage

美摄云服务方案:专为轻量化视频制作场景打造

JVM garbage collection mechanism
随机推荐
Get system volume across platforms in unity
软件测试年终总结报告模板
代码即数据
信息系统项目管理师---第七章 项目成本管理
LeetCode-515. Find the maximum value in each tree row
693. alternate bit binary number
WebRTC系列-网络传输之7-ICE补充之提名(nomination)与ICE_Model
Small program of C language practice (consolidate and deepen the understanding of knowledge points)
数据库-索引
【Cocos Creator 3.5.1】this.node.getPosition(this._curPos)的使用
The SCP command is used in the expect script. The perfect solution to the problem that the SCP command in the expect script cannot obtain the value
Navigation [machine learning]
NEON优化1:软件性能优化、降功耗怎么搞?
427-二叉树(617.合并二叉树、700.二叉搜索树中的搜索、98. 验证二叉搜索树、530.二叉搜索树的最小绝对差)
Unicast, multicast and broadcast of IP network communication
开门小例子学习十种用例图
《汇编语言-王爽》第3章笔记及实验
Neon optimization 1: how to optimize software performance and reduce power consumption?
Kubesphere cluster configuration NFS storage solution - favorite
Run opcua protocol demo on raspberry pie 4B to access kubeedge