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

📄 tiger.cs

📁 Tiger Tree Hash is constructed from two parts, the Tiger Hash Algorithm and Merkle Tree. The origina
💻 CS
📖 第 1 页 / 共 3 页
字号:
		{
			this.buf = new byte[64];
			this.block = new long[8];
			this.Initialize ();
		}

		public override bool CanTransformMultipleBlocks
		{
			get	{ return true;	}
		}

		public void Compress ()
		{
			long aa = 0L;
			long bb = 0L;
			long[] block = null;
			long cc = 0L;
			aa = this.a;
			bb = this.b;
			cc = this.c;
			block = this.block;
			this.RoundABC (block[0], 5);
			this.RoundBCA (block[1], 5);
			this.RoundCAB (block[2], 5);
			this.RoundABC (block[3], 5);
			this.RoundBCA (block[4], 5);
			this.RoundCAB (block[5], 5);
			this.RoundABC (block[6], 5);
			this.RoundBCA (block[7], 5);
			this.Schedule (block);
			this.RoundCAB (block[0], 7);
			this.RoundABC (block[1], 7);
			this.RoundBCA (block[2], 7);
			this.RoundCAB (block[3], 7);
			this.RoundABC (block[4], 7);
			this.RoundBCA (block[5], 7);
			this.RoundCAB (block[6], 7);
			this.RoundABC (block[7], 7);
			this.Schedule (block);
			this.RoundBCA (block[0], 9);
			this.RoundCAB (block[1], 9);
			this.RoundABC (block[2], 9);
			this.RoundBCA (block[3], 9);
			this.RoundCAB (block[4], 9);
			this.RoundABC (block[5], 9);
			this.RoundBCA (block[6], 9);
			this.RoundCAB (block[7], 9);
			this.a ^= aa;
			this.b -= bb;
			this.c += cc;
		}
     
		
		~Tiger ()
		{
			
		}

		protected override void HashCore (byte[] data, int nStart, int nSize)
		{
			byte[] buf = null;
			int nBufPos = 0;
			int nEnd = 0;
			int nToCopy = 0;
			this.lLen += ((long) nSize);
			buf = this.buf;
			nBufPos = this.nBufPos;
			nEnd = (nStart + nSize);
			while (nStart < nEnd)
			{
				nToCopy = ((int) (64 - nBufPos));
				if (nToCopy > nSize)
				{
					nToCopy = nSize;
				}
				Array.Copy (((Array) data), nStart, ((Array) buf), nBufPos, nToCopy);
				nStart += nToCopy;
				nBufPos += nToCopy;
				nSize -= nToCopy;
				if (64 <= nBufPos)
				{
					this.ProcessBlock ();
					nBufPos = 0;
					continue;
				}
				break;
			}
			this.nBufPos = nBufPos;
		}

		protected override byte[] HashFinal ()
		{
			byte[] buf = null;
			int nBufPos = 0;
			byte[] result = null;
			nBufPos = this.nBufPos;
			buf = this.buf;
			buf[nBufPos] = ((byte) 1);
			nBufPos++;
			if (56 <= nBufPos)
			{
				Array.Clear (((Array) buf), nBufPos, ((int) (64 - nBufPos)));
				this.ProcessBlock ();
				nBufPos = 0;
			}
			Array.Clear (((Array) buf), nBufPos, ((int) ((64 - nBufPos) - 8)));
			Tiger.LongToBytes (((long) (this.lLen << 3)), buf, 56);
			this.ProcessBlock ();
			result = new byte[24];
			Tiger.LongToBytes (this.a, result, 0);
			Tiger.LongToBytes (this.b, result, 8);
			Tiger.LongToBytes (this.c, result, 16);
			return result;
		}

		public override void Initialize ()
		{
			this.a = 81985529216486895L;
			this.b = -81985529216486896L;
			this.c = -1110518062304271993L;
			this.nBufPos = 0;
			this.lLen = 0L;
		}

		static void LongToBytes (long lVal, byte[] buf, int nIdx)
		{
			int nEnd = 0;
			nEnd = (nIdx + 8);
			while (nIdx < nEnd)
			{
				buf[nIdx] = ((byte) (lVal & 255L));
				lVal = ((long) (lVal >> 8));
				nIdx++;
			}
		}

		public void ProcessBlock ()

⌨️ 快捷键说明

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