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

📄 predefine.h

📁 rsa加密算法的vc实现
💻 H
字号:
#ifndef PREDEFINE_H
#define PREDEFINE_H

#include<cmath>
#include"stack.h"
#include"intNode.h"
const unsigned int FULL = 0xFFFFFFFF;
const unsigned int MAXDEC = 1000000000;
const static unsigned char HArray[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
 'A', 'B', 'C', 'D', 'E', 'F'};

const static unsigned int sta_p[] = {2, 7, 3, 5, 97, 39, 3, 37, 1109, 1877};

const static unsigned int r_laimda = 0x48c27395;
const static unsigned int r_c = 23;
const static double r_M = 100000000.;
const static double r_MM = 30000000.;
const static double r_cc = 113.;
const static double r_l = 8.;

unsigned int hdigit(unsigned char c)
{
	unsigned char hi,lo;

	hi = c >> 4;
	lo = c & 0x0f;
	if(hi == 0x04)
		return (int)(lo + 0x09);
	if(hi == 0x06)
		return (int)(lo + 0x09);
	return (unsigned int)lo;
}

void multi(const unsigned int& p1,const unsigned int& p2, unsigned int& high, unsigned int& low)
{
	unsigned int h1;
	unsigned int h2;
	unsigned int l1;
	unsigned int l2;

	h1 = (p1 >> 16);
	h2 = (p2 >> 16);
	l1 = (p1 & 0xFFFF);
	l2 = (p2 & 0xFFFF);

	high = h1 * h2;
	low = l1 * l2;

	unsigned int temp;
	unsigned int re;

	temp = h1 * l2;
	re = ((temp & 0xFFFF) << 16);
	high += (temp >> 16);

	temp = h2 * l1;
	re += ((temp & 0xFFFF) << 16);
	if(re < ((temp & 0xFFFF) << 16))
		++high;
	high += temp >> 16;

	low += re;
	if(low < re)
		++high;
}

intNode* backToFront(intNode* p)
{
	intNode* t1 = NULL;
	intNode* t2;
	while(p != NULL)
	{
		t2 = p->next;
		p->next = t1;
		t1 = p;
		p = t2;
	}
	return t1;
}
int FindZeroBit(unsigned int num)
{
	int cc = FULL >> 4;
	int Fbit = 3;
	while(num < cc)
	{
		cc >>= 4;
		Fbit += 4;
	}
	cc = FULL >> Fbit;
	while((cc & num) != num)
	{
		--Fbit;
		cc = FULL >> Fbit;
	}
	return Fbit;
}
bool TheLastNode(intNode*& t)
{
	if(t == NULL)
		return false;
	while(t->next != NULL)
		t = t->next;
	return true;
}
#endif

⌨️ 快捷键说明

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