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

📄 bigint.h

📁 密码学中用的大数类,用c++实现,可以实现基本的四则运算和密码学中的常用算法,如欧几里得算法等,
💻 H
字号:
/****************************************************************/
//大数运算库源文件:BigInt.cpp
//作者:zhezhe_lin@sina.com
//版本:3.0 (2007.6.11)
//说明:适用于MFC
/****************************************************************/



#include <iostream>
#include <string>
using namespace std;
#define BI_MAXLEN 40
#define DEC 10
#define HEX 16


class CBigInt
{
public:
    int m_nSign;
    int m_nLength;
    unsigned long m_ulValue[BI_MAXLEN];
	
    CBigInt();
    CBigInt(string str);
    ~CBigInt();
	
	//基本操作与运算    
    CBigInt& Mov(CBigInt& A);
    CBigInt& Mov(unsigned __int64 A);
    int Cmp(CBigInt& A); 
    CBigInt Add(CBigInt& A);
    CBigInt Add(long A);
    CBigInt Sub(CBigInt& A);
    CBigInt Sub(long A);
    CBigInt Mul(CBigInt& A);
    CBigInt Mul(long A);
    CBigInt Div(CBigInt& A);
    CBigInt Div(long A);
    CBigInt Mod(CBigInt& A);
    long Mod(long A); 
	
	//输入输出
    int InPutFromStr(CString& str, const unsigned int system);
    int OutPutToStr(CString& str, const unsigned int system);
	
	//欧几里德算法求:Y=X.Euc(A),使满足:YX mod A = 1
	
	CBigInt Euc(CBigInt& A);
	
	//蒙哥马利算法求:Y=X.Mon(A,B),使满足:X^A mod B = Y
    CBigInt Mon(CBigInt& A, CBigInt& B);
	
	
	//操作运算符重载
	
	CBigInt operator +(CBigInt& A);
	CBigInt operator +(long A);
			
	CBigInt operator -(CBigInt& A);
	CBigInt operator -(long A);

	CBigInt operator *(CBigInt& A);
	CBigInt operator *(long A);

	CBigInt operator /(CBigInt& A);
	CBigInt operator /(long A);

	CBigInt operator %(CBigInt& A);


};

⌨️ 快捷键说明

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