-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrsaDriver.cpp
28 lines (23 loc) · 872 Bytes
/
rsaDriver.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "RSA.h"
#include "BigInt.h"
#include <cmath>
#include<iostream>
#define RAND_LIMIT32 0x7FFFFFFF
using namespace RSAUtil;
int main(int argc, char*argv[]){ /*********************************************************
* A Simple Driver
* *******************************************************
*/
unsigned long int *a;
unsigned long int arr[4];
a=&arr[0];
RSA myRSA;
BigInt message, cipher, deciphered;
message = int(((double)std::rand()/RAND_MAX)*RAND_LIMIT32);
message.toULong(a,4);
cipher = myRSA.encrypt(message);
deciphered = myRSA.decrypt(cipher);
std::cout<<*a<<std::endl;
// std::cout<<"message "<<message.toString();
std::cout<<"message: "<<message.toHexString()<<"\tcipher: "<<cipher.toHexString()<<"\tdeciphered: "<<deciphered.toHexString()<<std::endl;
}