亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? biginteger.cs

?? JAVA實現的RSA公鑰加密方法
?? CS
?? 第 1 頁 / 共 5 頁
字號:
				if(dividendNeg)
					return -remainder;

				return remainder;
			}
		}


		//***********************************************************************
		// Overloading of bitwise AND operator
		//***********************************************************************

		public static BigInteger operator &(BigInteger bi1, BigInteger bi2)
		{
			BigInteger result = new BigInteger();

			int len = (bi1.dataLength > bi2.dataLength) ? bi1.dataLength : bi2.dataLength;

			for(int i = 0; i < len; i++)
			{
				uint sum = (uint)(bi1.data[i] & bi2.data[i]);
				result.data[i] = sum;
			}

			result.dataLength = maxLength;

			while(result.dataLength > 1 && result.data[result.dataLength-1] == 0)
				result.dataLength--;

			return result;
		}


		//***********************************************************************
		// Overloading of bitwise OR operator
		//***********************************************************************

		public static BigInteger operator |(BigInteger bi1, BigInteger bi2)
		{
			BigInteger result = new BigInteger();

			int len = (bi1.dataLength > bi2.dataLength) ? bi1.dataLength : bi2.dataLength;

			for(int i = 0; i < len; i++)
			{
				uint sum = (uint)(bi1.data[i] | bi2.data[i]);
				result.data[i] = sum;
			}

			result.dataLength = maxLength;

			while(result.dataLength > 1 && result.data[result.dataLength-1] == 0)
				result.dataLength--;

			return result;
		}


		//***********************************************************************
		// Overloading of bitwise XOR operator
		//***********************************************************************

		public static BigInteger operator ^(BigInteger bi1, BigInteger bi2)
		{
			BigInteger result = new BigInteger();

			int len = (bi1.dataLength > bi2.dataLength) ? bi1.dataLength : bi2.dataLength;

			for(int i = 0; i < len; i++)
			{
				uint sum = (uint)(bi1.data[i] ^ bi2.data[i]);
				result.data[i] = sum;
			}

			result.dataLength = maxLength;

			while(result.dataLength > 1 && result.data[result.dataLength-1] == 0)
				result.dataLength--;

			return result;
		}


		//***********************************************************************
		// Returns max(this, bi)
		//***********************************************************************

		public BigInteger max(BigInteger bi)
		{
			if(this > bi)
				return (new BigInteger(this));
			else
				return (new BigInteger(bi));
		}


		//***********************************************************************
		// Returns min(this, bi)
		//***********************************************************************

		public BigInteger min(BigInteger bi)
		{
			if(this < bi)
				return (new BigInteger(this));
			else
				return (new BigInteger(bi));

		}


		//***********************************************************************
		// Returns the absolute value
		//***********************************************************************

		public BigInteger abs()
		{
			if((this.data[maxLength - 1] & 0x80000000) != 0)
				return (-this);
			else
				return (new BigInteger(this));
		}


		//***********************************************************************
		// Returns a string representing the BigInteger in base 10.
		//***********************************************************************

		public override string ToString()
		{
			return ToString(10);
		}


		//***********************************************************************
		// Returns a string representing the BigInteger in sign-and-magnitude
		// format in the specified radix.
		//
		// Example
		// -------
		// If the value of BigInteger is -255 in base 10, then
		// ToString(16) returns "-FF"
		//
		//***********************************************************************

		public string ToString(int radix)
		{
			// if(radix < 2 || radix > 36)
			// throw (new ArgumentException("Radix must be >= 2 and <= 36"));
			//
			// string charSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

			if(radix < 2 || radix > 95)
				throw (new ArgumentException("Radix must be >= 2 and <= 95"));

			string charSet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_=!@#$%^&*()[]{}|;:,.<>/?`~ \\\'\"+-";
			string result = "";

			BigInteger a = this;

			bool negative = false;
			if((a.data[maxLength-1] & 0x80000000) != 0)
			{
				negative = true;
				try
				{
					a = -a;
				}
				catch(Exception) {}
			}

			BigInteger quotient = new BigInteger();
			BigInteger remainder = new BigInteger();
			BigInteger biRadix = new BigInteger(radix);

			if(a.dataLength == 1 && a.data[0] == 0)
				result = "0";
			else
			{
				while(a.dataLength > 1 || (a.dataLength == 1 && a.data[0] != 0))
				{
					singleByteDivide(a, biRadix, quotient, remainder);

					// if(remainder.data[0] < 10)
					// result = remainder.data[0] + result;
					// else
					// result = charSet[(int)remainder.data[0] - 10] + result;

					result = charSet[(int)remainder.data[0]] + result;

					a = quotient;
				}
				if(negative)
					result = "-" + result;
			}

			return result;
		}



		//***********************************************************************
		// Returns a hex string showing the contains of the BigInteger
		//
		// Examples
		// -------
		// 1) If the value of BigInteger is 255 in base 10, then
		//    ToHexString() returns "FF"
		//
		// 2) If the value of BigInteger is -255 in base 10, then
		//    ToHexString() returns ".....FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF01",
		//    which is the 2's complement representation of -255.
		//
		//***********************************************************************

		public string ToHexString()
		{
			string result = data[dataLength - 1].ToString("X");

			for(int i = dataLength - 2; i >= 0; i--)
			{
				result += data[i].ToString("X8");
			}

			return result;
		}



		//***********************************************************************
		// Modulo Exponentiation
		//***********************************************************************

		public BigInteger modPow(BigInteger exp, BigInteger n)
		{
			if((exp.data[maxLength-1] & 0x80000000) != 0)
				throw (new ArithmeticException("Positive exponents only."));

			BigInteger resultNum = 1;
			BigInteger tempNum;
			bool thisNegative = false;

			if((this.data[maxLength-1] & 0x80000000) != 0)   // negative this
			{
				tempNum = -this % n;
				thisNegative = true;
			}
			else
				tempNum = this % n;  // ensures (tempNum * tempNum) < b^(2k)

			if((n.data[maxLength-1] & 0x80000000) != 0)   // negative n
				n = -n;

			// calculate constant = b^(2k) / m
			BigInteger constant = new BigInteger();

			int i = n.dataLength << 1;
			constant.data[i] = 0x00000001;
			constant.dataLength = i + 1;

			constant = constant / n;
			int totalBits = exp.bitCount();
			int count = 0;

			// perform squaring and multiply exponentiation
			for(int pos = 0; pos < exp.dataLength; pos++)
			{
				uint mask = 0x01;
				//Console.WriteLine("pos = " + pos);

				for(int index = 0; index < 32; index++)
				{
					if((exp.data[pos] & mask) != 0)
						resultNum = BarrettReduction(resultNum * tempNum, n, constant);

					mask <<= 1;

					tempNum = BarrettReduction(tempNum * tempNum, n, constant);


					if(tempNum.dataLength == 1 && tempNum.data[0] == 1)
					{
						if(thisNegative && (exp.data[0] & 0x1) != 0)    //odd exp
							return -resultNum;
						return resultNum;
					}
					count++;
					if(count == totalBits)
						break;
				}
			}

			if(thisNegative && (exp.data[0] & 0x1) != 0)    //odd exp
				return -resultNum;

			return resultNum;
		}



		//***********************************************************************
		// Fast calculation of modular reduction using Barrett's reduction.
		// Requires x < b^(2k), where b is the base.  In this case, base is
		// 2^32 (uint).
		//
		// Reference [4]
		//***********************************************************************

		private BigInteger BarrettReduction(BigInteger x, BigInteger n, BigInteger constant)
		{
			int k = n.dataLength,
				kPlusOne = k+1,
				kMinusOne = k-1;

			BigInteger q1 = new BigInteger();

			// q1 = x / b^(k-1)
			for(int i = kMinusOne, j = 0; i < x.dataLength; i++, j++)
				q1.data[j] = x.data[i];
			q1.dataLength = x.dataLength - kMinusOne;
			if(q1.dataLength <= 0)
				q1.dataLength = 1;


			BigInteger q2 = q1 * constant;
			BigInteger q3 = new BigInteger();

			// q3 = q2 / b^(k+1)
			for(int i = kPlusOne, j = 0; i < q2.dataLength; i++, j++)
				q3.data[j] = q2.data[i];
			q3.dataLength = q2.dataLength - kPlusOne;
			if(q3.dataLength <= 0)
				q3.dataLength = 1;


			// r1 = x mod b^(k+1)
			// i.e. keep the lowest (k+1) words
			BigInteger r1 = new BigInteger();
			int lengthToCopy = (x.dataLength > kPlusOne) ? kPlusOne : x.dataLength;
			for(int i = 0; i < lengthToCopy; i++)
				r1.data[i] = x.data[i];
			r1.dataLength = lengthToCopy;


			// r2 = (q3 * n) mod b^(k+1)
			// partial multiplication of q3 and n

			BigInteger r2 = new BigInteger();
			for(int i = 0; i < q3.dataLength; i++)
			{
				if(q3.data[i] == 0)     continue;

				ulong mcarry = 0;
				int t = i;
				for(int j = 0; j < n.dataLength && t < kPlusOne; j++, t++)
				{
					// t = i + j
					ulong val = ((ulong)q3.data[i] * (ulong)n.data[j]) +
						(ulong)r2.data[t] + mcarry;

					r2.data[t] = (uint)(val & 0xFFFFFFFF);
					mcarry = (val >> 32);
				}

				if(t < kPlusOne)
					r2.data[t] = (uint)mcarry;
			}
			r2.dataLength = kPlusOne;
			while(r2.dataLength > 1 && r2.data[r2.dataLength-1] == 0)
				r2.dataLength--;

			r1 -= r2;
			if((r1.data[maxLength-1] & 0x80000000) != 0)        // negative
			{
				BigInteger val = new BigInteger();
				val.data[kPlusOne] = 0x00000001;
				val.dataLength = kPlusOne + 1;
				r1 += val;
			}

			while(r1 >= n)
				r1 -= n;

			return r1;
		}


		//***********************************************************************
		// Returns gcd(this, bi)
		//***********************************************************************

		public BigInteger gcd(BigInteger bi)
		{
			BigInteger x;
			BigInteger y;

			if((data[maxLength-1] & 0x80000000) != 0)     // negative
				x = -this;
			else
				x = this;

			if((bi.data[maxLength-1] & 0x80000000) != 0)     // negative
				y = -bi;
			else
				y = bi;

			BigInteger g = y;

			while(x.dataLength > 1 || (x.dataLength == 1 && x.data[0] != 0))
			{
				g = x;
				x = y % x;
				y = g;
			}

			return g;
		}


		//***********************************************************************
		// Populates "this" with the specified amount of random bits
		//***********************************************************************

		public void genRandomBits(int bits, Random rand)
		{
			int dwords = bits >> 5;
			int remBits = bits & 0x1F;

			if(remBits != 0)
				dwords++;

			if(dwords > maxLength)
				throw (new ArithmeticException("Number of required bits > maxLength."));

			for(int i = 0; i < dwords; i++)
				data[i] = (uint)(rand.NextDouble() * 0x100000000);

			for(int i = dwords; i < maxLength; i++)
				data[i] = 0;

			if(remBits != 0)
			{
				uint mask = (uint)(0x01 << (remBits-1));
				data[dwords-1] |= mask;

				mask = (uint)(0xFFFFFFFF >> (32 - remBits));
				data[dwords-1] &= mask;
			}
			else
				data[dwords-1] |= 0x80000000;

			dataLength = dwords;

			if(dataLength == 0)
				dataLength = 1;
		}


		//***********************************************************************
		// Returns the position of the most significant bit in the BigInteger.
		//
		// Eg.  The result is 0, if the value of BigInteger is 0...0000 0000
		//      The result is 1, if the value of BigInteger is 0...0000 0001
		//      The result is 2, if the value of BigInteger is 0...0000 0010
		//      The result is 2, if the value of BigInteger is 0...0000 0011

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲天堂网中文字| 91精品国产综合久久福利| 国产午夜三级一区二区三| 久久精品免费观看| 久久免费国产精品| 成人黄色小视频在线观看| 国产精品久久久久aaaa| 91麻豆6部合集magnet| 一区二区视频在线| 91精品国产美女浴室洗澡无遮挡| 日韩不卡一区二区| 日韩久久精品一区| 国产jizzjizz一区二区| 亚洲欧美日韩成人高清在线一区| 日本久久一区二区三区| 日韩黄色在线观看| 久久久久久久久久久久久久久99| www.色精品| 亚洲妇熟xx妇色黄| 久久一二三国产| 91福利资源站| 久久99热国产| 亚洲欧美国产77777| 宅男噜噜噜66一区二区66| 国产东北露脸精品视频| 亚洲精品午夜久久久| 日韩一区二区在线观看视频播放| 国产成人免费高清| 日韩中文欧美在线| 国产精品久久久久久福利一牛影视 | 欧美老肥妇做.爰bbww视频| 蜜臀精品久久久久久蜜臀| 亚洲国产精品99久久久久久久久| 欧美图片一区二区三区| 激情另类小说区图片区视频区| 亚洲人成在线观看一区二区| 日韩欧美中文一区二区| 99re热视频这里只精品| 日本视频在线一区| 中文字幕中文在线不卡住| 91精品国产综合久久久久| a在线播放不卡| 精品无人区卡一卡二卡三乱码免费卡| 亚洲视频精选在线| 久久视频一区二区| 欧美一级片在线| 欧美在线你懂得| 大陆成人av片| 狠狠色丁香婷婷综合久久片| 亚洲第一福利一区| 亚洲欧美色图小说| 国产精品蜜臀av| 久久精品一区二区三区av| 在线不卡免费欧美| 日本国产一区二区| 9l国产精品久久久久麻豆| 国内精品久久久久影院色| 亚洲va韩国va欧美va| 亚洲免费伊人电影| 国产精品九色蝌蚪自拍| 欧美在线不卡一区| 韩国v欧美v亚洲v日本v| 337p亚洲精品色噜噜狠狠| 久久99精品一区二区三区 | 国产乱码精品一品二品| 午夜久久久影院| 亚洲伦在线观看| 国产精品欧美久久久久无广告| 精品久久免费看| 日韩免费成人网| 日韩亚洲欧美在线| 欧美一区二区精品在线| 欧美日韩久久久久久| 在线国产电影不卡| 精品视频一区二区不卡| 欧美视频日韩视频| 欧美日韩日日骚| 欧美日韩国产一二三| 欧美私人免费视频| 欧美精品电影在线播放| 欧美精品久久久久久久久老牛影院| 欧美午夜免费电影| 欧美午夜不卡视频| 欧美日本高清视频在线观看| 欧美精品一级二级三级| 91精选在线观看| 精品国产在天天线2019| 欧美大胆人体bbbb| 久久亚洲影视婷婷| 国产精品不卡视频| 亚洲制服欧美中文字幕中文字幕| 亚洲一区二区三区小说| 午夜电影一区二区三区| 日韩高清在线观看| 国产一区二区剧情av在线| 国产91精品入口| 一本大道久久a久久综合| 欧美亚洲国产一区二区三区va| 欧美日韩国产一区二区三区地区| 欧美三级日本三级少妇99| 91精品国产综合久久小美女| 久久久久久免费| 日韩美女视频一区二区| 天堂va蜜桃一区二区三区 | 久久精品一区二区三区四区| 中文字幕中文字幕一区| 天天综合天天综合色| 韩国毛片一区二区三区| 色综合亚洲欧洲| 日韩限制级电影在线观看| 欧美激情在线一区二区三区| 亚洲综合免费观看高清完整版在线| 天堂va蜜桃一区二区三区| 国产乱人伦偷精品视频免下载| 99热99精品| 欧美一区二区不卡视频| 中文字幕不卡的av| 性欧美疯狂xxxxbbbb| 国产伦精品一区二区三区免费迷 | 成人免费的视频| 欧美三级三级三级| 国产日韩欧美精品电影三级在线| 亚洲综合小说图片| 国产成人亚洲精品青草天美| 欧美日韩一区不卡| 日本一区二区成人在线| 天天色 色综合| 成人动漫视频在线| 7777精品久久久大香线蕉| 欧美国产日韩一二三区| 日韩精品福利网| 91农村精品一区二区在线| 精品国产1区2区3区| 亚洲一二三专区| 国产ts人妖一区二区| 欧美一区二区三区免费大片| 自拍偷在线精品自拍偷无码专区| 免费精品视频最新在线| 在线观看不卡视频| 国产精品久久久久久久久久久免费看 | 欧美高清一级片在线| 国产精品灌醉下药二区| 麻豆freexxxx性91精品| 欧美午夜电影在线播放| 成人欧美一区二区三区白人| 国内一区二区视频| 91麻豆精品国产91久久久久| 一级中文字幕一区二区| 91香蕉视频黄| 中国色在线观看另类| 国产乱一区二区| 精品国产制服丝袜高跟| 日韩一区欧美二区| 在线观看91精品国产入口| ...中文天堂在线一区| 国产精品18久久久| 久久婷婷国产综合精品青草| 久久99在线观看| 日韩欧美高清一区| 青青草成人在线观看| 欧美精选在线播放| 亚洲成人午夜影院| 欧美性色综合网| 亚洲国产中文字幕在线视频综合| 91尤物视频在线观看| 成人免费在线视频观看| 99精品国产视频| 亚洲人成精品久久久久久| 99精品一区二区| 亚洲美女免费在线| 欧美视频在线播放| 午夜欧美大尺度福利影院在线看| 欧美日韩免费观看一区三区| 亚洲国产日韩av| 制服丝袜av成人在线看| 麻豆精品精品国产自在97香蕉 | 色婷婷激情一区二区三区| 综合中文字幕亚洲| 91蝌蚪porny成人天涯| 亚洲精品一二三四区| 欧美午夜精品理论片a级按摩| 亚洲夂夂婷婷色拍ww47| 欧美日韩另类国产亚洲欧美一级| 香蕉乱码成人久久天堂爱免费| 欧美精品日韩综合在线| 麻豆成人久久精品二区三区红| 精品成人私密视频| 国产成人精品免费| 亚洲人成精品久久久久久| 欧美日韩亚洲国产综合| 美国毛片一区二区| 欧美韩国日本一区| 欧美亚洲综合久久| 久久精品999| 日韩一区日韩二区| 3751色影院一区二区三区| 激情久久五月天| 亚洲黄色尤物视频| 日韩亚洲欧美中文三级| 成人高清在线视频|