当前位置:网站首页>关于RSA加密解密原理
关于RSA加密解密原理
2022-06-13 08:38:00 【Array_new】
前言:
随着我们的学习的不断深入,信息的安全也愈加重要,我们发布的代码中可能含有我们的私密信息,比如对接支付宝沙箱api,下载一些专业软件时就需要我们输入公钥和私钥以此来验证我们的身份信息,就相当于用钥匙去开锁一样,公钥代表着锁,私钥代表着开锁的钥匙,而公钥与私钥也是可以互换的,理解完这点,下面就详细说一下他们的原理。
RSA密钥的分发:
首先取俩个质数(p,q),N=pq
然后求他们的欧拉函数 T = (p-1)(q-1)
取出公钥E 它的规则是1.是一个质数。
2.1<公钥<T ;
3.不是T的因子
选出完公钥E后计算出私钥D (D*E)%T=1
这样关于公钥和私钥的分发就完成了
例如p=3,q=11 N=pq=33
T=(3-1)(11-1)=20
随机选出一个公钥E=3那么密钥可取D=7
公钥E(3,33)私钥D(7,33)
根据下边的加密公式对对1 2 3加密成
1,29,9
根据下边的解密公式可以解出原来的数字为
1,2,3
密钥加密:(明文^E)%N=密文
密钥解密:(密文^E)%N=明文
RSA公开密钥密码体制的原理是:根据数论,寻求两个大素数比较简单,而将它们的乘积进行因式分解却极其困难,因此可以将乘积公开作为加密密钥
结果:
边栏推荐
猜你喜欢
2021-04-16
Maternal and infant supplies wholesale industry uses management software to improve efficiency and realize cost reduction and efficiency increase
MySQL queries difference sets (missing data) by linking tables based on an associated field
VS安装VAssistX插件导致WPF-XAML文件输入中文出现乱码问题解决方案
How to modify desktop path in win10 system
The method of SolidWorks modifying text font in engineering drawing
微服务系统架构搭建一:环境搭建
When submitting the laravel admin form and using the required verification, an error is reported when the value is 0
Remote access and control
anaconda下安装pytorch
随机推荐
Data accuracy problems caused by inconsistent data types during sum in MySQL
MySQL query exercise 3
Form exercise 2
Numeric types in SQL. Try to avoid using null as the default value
3、 JS notes
Use of addeventlistener in JS
WARNING:tornado.access:404 GET /favicon.ico (172.16.8.1) 1.84ms [附静态文件设置]
Redis subscribe connection timeout interrupt problem solution
0.一些自己初学Solidworks的疑惑
redis. exceptions. ConnectionError: Error 111 connecting to 172.16.8.128:6379. Connection refused.
DIY无人机(匿名拓控者P2+F330机架)
SQL injection experiment
Microservice Project Construction II: database design
Microservice project construction III: automatic code generation
Redis分布式集群搭建
Buuctf web (V)
Four ways to install MySQL in Linux
WARNING:tornado. access:404 GET /favicon. ICO (172.16.8.1) 1.84ms [with static file settings]
天猫商品详情接口,天猫商品优惠券接口,天猫api接口,天猫价格监控接口,天猫比价接口,品牌维权接口,天猫销量api接口,接口代码可对接数据分析业务,品牌维权,比价业务,行业分析业务接口代码分享
Verify the word limit of textarea input box. Only prompt but no submission limit