本文共 378 字,大约阅读时间需要 1 分钟。
密钥生成 | n: n=p*q(p和q必须保密) |
---|---|
φ(n):φ(n)=(p-1)*(q-1) | |
公钥e: gcd(e,φ(n))=1(既 e与φ(n)互素) | |
私钥d:ed≡1 mod φ(n) |
加密算法 | c≡m^e(mod n) |
---|---|
解密算法 | m≡c^d(mod n) |
eg:
假设需要加密的明文信息为m=14,选择:e=3,p=5,q=11,试说明使用RSA算法的加密和解密过程及结果? 解: n=p * q=55 φ(n)=(p-1)(q-1)=410=40 根据ed≡1 mod φ(n) 又3d mod 40=1 得出d=27 公钥(e,n)=(3,55)得到密文c=m^e mod 55=14^3 mod 55=49 私钥(d,n)=(27,55)得到明文m=c^d mod 55=49^27 mod 55=14转载地址:http://nwowi.baihongyu.com/