⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ras.c

📁 RSA算法的C语言实现 RSA算法的C语言实现
💻 C
字号:
#include <stdio.h>
#include <math.h>
main()
{
    int apube=7;
    int apubn=123;
    int bpube=13;
    int bpubn=51;
    int aprid=23;
    int aprin=123;
    int bprid=5;
    int bprin=51;
    int msg;
    long buff;
    printf("Input the message:");
    scanf("%d",&msg);
    buff=(long)pow(msg,aprid)%aprin;
    printf("Using private key of A:%d\n",buff);
    buff=pow(buff,bpube)-(int)(pow(buff,bpube)/bpubn)*bpubn;
    printf("Using public key of B:%d\n",buff);
    printf("B get the msg.\n");
    buff=pow(buff,bprid)-(int)(pow(buff,bprid)/bprin)*bprin;
    printf("Using private key of B:%d\n",buff);
    buff=pow(buff,apube)-(int)(pow(buff,apube)/apubn)*apubn;
    printf("Using public key of A:%d\n",buff);
	printf("The msg is sent by A.");
    getch();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -