rsa.cpp

来自「rsa算法/// ////」· C++ 代码 · 共 47 行

CPP
47
字号
// 测试代码
//

#include "LargeInt.h"
#include <iostream>
using namespace std;
using namespace panic;

int main(int argc, char* argv[])
{
	
	CLargeInt p,q,n,d,e,m,c;
	cout << "Create Random P,Q,E,M" << endl;
	CLargeInt::CreateRandom(p,2048);
	CLargeInt::CreateRandom(q,2048);
	CLargeInt::CreateRandom(e,128);
	CLargeInt::CreateRandom(m,64);
	p.Print();
	q.Print();
	e.Print();
	m.Print();

	cout << "Create Prime P,Q,E" << endl;
	CLargeInt::CreatePrime(p);
	CLargeInt::CreatePrime(q);
	CLargeInt::CreatePrime(e);

	p.Print();
	q.Print();
	e.Print();

	cout << "Create D,N" << endl;
	CLargeInt::RSACreate(p,q,e,d,n);
	d.Print();
	n.Print();

	cout << "Encode M->C" << endl;
	CLargeInt::RSAEncode(n,d,m,c);
	c.Print();
	
	cout << "Decode C->M" << endl;
	CLargeInt::RSADecode(n,e,c,m);
	m.Print();
	return 0;
}

⌨️ 快捷键说明

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