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

📄 tiger.cs

📁 Tiger Tree Hash is constructed from two parts, the Tiger Hash Algorithm and Merkle Tree. The origina
💻 CS
📖 第 1 页 / 共 3 页
字号:
		{
			long[] block = null;
			byte[] buf = null;
			int nI = 0;
			int nPos = 0;
			nPos = 0;
			block = this.block;
			buf = this.buf;
			while (nPos < 64)
			{
				block[nI] = ((long) ((((((((((long) buf[(nPos + 7)]) << 56) | ((((long) buf[(nPos + 6)]) & 255L) << 48)) | ((((long) buf[(nPos + 5)]) & 255L) << 40)) | ((((long) buf[(nPos + 4)]) & 255L) << 32)) | ((((long) buf[(nPos + 3)]) & 255L) << 24)) | ((((long) buf[(nPos + 2)]) & 255L) << 16)) | ((((long) buf[(nPos + 1)]) & 255L) << 8)) | (((long) buf[nPos]) & 255L)));
				nPos += 8;
				nI++;
			}
			this.Compress ();
		}

		public void RoundABC (long x, int mul)
		{
			long c = 0L;
			int ch = 0;
			int cl = 0;
			long[] T = null;
			T = Tiger.T;
			c = this.c;
			c ^= x;
			ch = ((int) (c >> 32));
			cl = ((int) c);
			this.a -= (((T[(cl & 255)] ^ T[((int) (((cl >> 16) & 255) + 256))]) ^ T[((ch & 255) + 512)]) ^ T[((int) (((ch >> 16) & 255) + 768))]);
			this.b += (((T[(((cl >> 8) & 255) + 768)] ^ T[((int) (((cl >> 24) & 255) + 512))]) ^ T[(((ch >> 8) & 255) + 256)]) ^ T[((int) ((ch >> 24) & 255))]);
			this.b *= ((long) mul);
			this.c = c;
		}

		public void RoundBCA (long x, int mul)
		{
			long a = 0L;
			int ah = 0;
			int al = 0;
			long[] T = null;
			T = Tiger.T;
			a = this.a;
			a ^= x;
			ah = ((int) (a >> 32));
			al = ((int) a);
			this.b -= (((T[(al & 255)] ^ T[((int) (((al >> 16) & 255) + 256))]) ^ T[((ah & 255) + 512)]) ^ T[((int) (((ah >> 16) & 255) + 768))]);
			this.c += (((T[(((al >> 8) & 255) + 768)] ^ T[((int) (((al >> 24) & 255) + 512))]) ^ T[(((ah >> 8) & 255) + 256)]) ^ T[((int) ((ah >> 24) & 255))]);
			this.c *= ((long) mul);
			this.a = a;
		}

		public void RoundCAB (long x, int mul)
		{
			long b = 0L;
			int bh = 0;
			int bl = 0;
			long[] T = null;
			T = Tiger.T;
			b = this.b;
			b ^= x;
			bh = ((int) (b >> 32));
			bl = ((int) b);
			this.c -= (((T[(bl & 255)] ^ T[((int) (((bl >> 16) & 255) + 256))]) ^ T[((bh & 255) + 512)]) ^ T[((int) (((bh >> 16) & 255) + 768))]);
			this.a += (((T[(((bl >> 8) & 255) + 768)] ^ T[((int) (((bl >> 24) & 255) + 512))]) ^ T[(((bh >> 8) & 255) + 256)]) ^ T[((int) ((bh >> 24) & 255))]);
			this.a *= ((long) mul);
			this.b = b;
		}

		public void Schedule (long[] x)
		{
			int _Vb_t_i4_0 = 0;
			_Vb_t_i4_0 = 0;
			x[_Vb_t_i4_0] -= (x[7] ^ -6510615555426900571L);
			x[1] = (x[1] ^ x[0]);
			_Vb_t_i4_0 = 2;
			x[_Vb_t_i4_0] += x[1];
			_Vb_t_i4_0 = 3;
			x[_Vb_t_i4_0] -= ((long) (x[2] ^ ((~ x[1]) << 19)));
			x[4] = (x[4] ^ x[3]);
			_Vb_t_i4_0 = 5;
			x[_Vb_t_i4_0] += x[4];
			_Vb_t_i4_0 = 6;
			x[_Vb_t_i4_0] -= ((long) (x[5] ^ (((~ x[4]) >> 23) & 2199023255551L)));
			x[7] = (x[7] ^ x[6]);
			_Vb_t_i4_0 = 0;
			x[_Vb_t_i4_0] += x[7];
			_Vb_t_i4_0 = 1;
			x[_Vb_t_i4_0] -= ((long) (x[0] ^ ((~ x[7]) << 19)));
			x[2] = (x[2] ^ x[1]);
			_Vb_t_i4_0 = 3;
			x[_Vb_t_i4_0] += x[2];
			_Vb_t_i4_0 = 4;
			x[_Vb_t_i4_0] -= ((long) (x[3] ^ (((~ x[2]) >> 23) & 2199023255551L)));
			x[5] = (x[5] ^ x[4]);
			_Vb_t_i4_0 = 6;
			x[_Vb_t_i4_0] += x[5];
			_Vb_t_i4_0 = 7;
			x[_Vb_t_i4_0] -= (x[6] ^ 81985529216486895L);
		}

		public static bool SelfTest ()
		{
			ASCIIEncoding enc = null;
			byte[] hash = null;
			int nI = 0;
			string TEST_DATA = null;
			byte[] TEST_HASH = null;
			Tiger tg = null;
			int _Vb_t_i4_0 = 0;
			byte[] _Vb_t_array_0 = null;
			TEST_DATA = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
			_Vb_t_array_0 = new byte[] { ((byte) 15), ((byte) 123), ((byte) 249), ((byte) 161), ((byte) 155), ((byte) 156), ((byte) 88), ((byte) 242), ((byte) 183), ((byte) 97), 
										   ((byte) 13), ((byte) 247), ((byte) 232), ((byte) 79), ((byte) 10), ((byte) 195), ((byte) 167), ((byte) 28), ((byte) 99), ((byte) 30), 
										   ((byte) 123), ((byte) 83), ((byte) 247), ((byte) 142) };
			TEST_HASH = _Vb_t_array_0;
			tg = new Tiger ();
			tg.Initialize ();
			enc = new ASCIIEncoding ();
			hash = tg.ComputeHash (enc.GetBytes (TEST_DATA));
			if (hash.Length != TEST_HASH.Length)
			{
				return false;
			}
			_Vb_t_i4_0 = (TEST_HASH.Length - 1);
			for (nI = 0; (nI <= _Vb_t_i4_0); nI++)
			{
				if (hash[nI] != TEST_HASH[nI])
				{
					return false;
				}
			}
			return true;
		}

	}
}

⌨️ 快捷键说明

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