下载频道> 资源分类> 编程语言> C源码> 实例259 RSA加密

标题:实例259 RSA加密
分享到:

所属分类: C源码 资源类型:程序源码 文件大小: 1.81 KB 上传时间: 2017-07-15 23:01:00 下载次数: 10 资源积分:1分 提 供 者: admin 实例259 RSA加密
内容:
#include <stdio.h>
int candp(int a,int b,int c)
{ int r=1;
b=b+1;
while(b!=1)
{
    r=r*a;
    r=r%c;
    b--;
}
printf("%d\n",r);
return r;
}
void main()
{
int p,q,e,d,m,n,t,c,r;
char s;
printf("please input the p,q: ");
scanf("%d%d",&p,&q);
n=p*q;
printf("the n is %3d\n",n);
t=(p-1)*(q-1);
printf("the t is %3d\n",t);
printf("please input the e: ");
scanf("%d",&e);
if(e<1||e>t)
{
     printf("e is error,please input again: ");
     scanf("%d",&e);
}
d=1;
while(((e*d)%t)!=1)   d++;
printf("then caculate out that the d is %d\n",d);
printf("the cipher please input 1\n");
printf("the plain please input 2\n");
scanf("%d",&r);
switch(r)
{
    case 1: printf("input the m: "); /*输入要加密的明文数字*/
            scanf("%d",&m);
            c=candp(m,e,n);
            printf("the cipher is %d\n",c);break;
    case 2: printf("input the c: "); /*输入要解密的密文数字*/
            scanf("%d",&c);
            m=candp(c,d,n);
            printf("the cipher is %d\n",m);break;
}
getch();
}
 

文件列表(点击上边下载按钮,如果是垃圾文件请在下面评价差评或者投诉):

实例259 RSA加密
实例259 RSA加密\www.gusucode.com
实例259 RSA加密\文件说明.txt
实例259 RSA加密\www.gusucode.com.txt
实例259 RSA加密\www.gusucode.com\259.c
实例259 RSA加密\【谷速代码】-免费源码.url

关键词: 实例

相关推荐

Top_arrow
回到顶部
联系方式| 版权声明| 招聘信息| 广告服务| 银行汇款| 法律顾问| 兼职技术| 付款方式| 关于我们|
网站客服网站客服 程序员兼职招聘 程序员兼职招聘
沪ICP备19040327号-3
公安备案号:沪公网安备 31011802003874号
库纳格流体控制系统(上海)有限公司 版权所有
Copyright © 1999-2014, GUSUCODE.COM, All Rights Reserved