下面是编程之家 jb51.cc 通过网络收集整理的代码片段。
编程之家小编现在分享给大家,也给大家做个参考。
//
// main.cpp
// RSA
//
// Created by liujan on 10/21/14.
// Copyright (c) 2014 liujan. All rights reserved.
//
#include
#include "cmath"
using namespace std;
long long p = 1949,q = 3413;
long long N = p * q;
long long e = 13007,d = 511;
//对a的b次幂取模 m(大数取模)
long long Mod(long long a,long long b,long long m){
long long r = 1;
for (long long j = 0; j < b; j++){
r = (r * a) % m;
}
return r;
}
//对输入信息进行rsa编码
long long * rSAEncode(string message){
size_t length = message.length();
long long *ascii = new long long[length]; //存储信息的每个字符
long long *code = new long long[lengt