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

📄 llrsa.cpp

📁 rsa加密算法很好的例子
💻 CPP
字号:
// LLrsa.cpp: implementation of the CLLrsa class.
//
//////////////////////////////////////////////////////////////////////

#include <iostream.h>

#include "LLrsa.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CLLrsa::CLLrsa()
{

	head = 0; // no elements in start
	tail = 0;
}

CLLrsa::~CLLrsa()
{

}

bool CLLrsa::insert(long e,long v)
{

	//create a new element
	CLLrsaNode *temp = new CLLrsaNode();
	temp->eValue = e;
	temp->value = v;

	if (head == 0)
	{ //insert the first element
		head = tail = temp;
	}
	else 
	{
		tail->next = temp;
		temp->prev = tail;

		tail = temp;
	}

	return true;
}

//print all values
void CLLrsa::print()
{
	CLLrsaNode *temp = head;

	while(temp != 0) {
		cout << endl << temp->eValue << ":" << temp->value;
		temp = temp->next;
	}

}

// calculate which exponent should be added now
long CLLrsa::getNextToAdd(long &mye_add,long mye,long e)
{
	CLLrsaNode *temp = tail;

	while(temp != 0)
	{
		if (temp->eValue + mye <= e)
		{
			mye_add = temp->eValue;
			return temp->value;
		}

		temp = temp->prev;
	}

	mye_add = 1;
	return head->value;
}

⌨️ 快捷键说明

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