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

📄 tigerdigest.java

📁 java 文件下载器。可自定义
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			processBlock();
		bOff = 0;
	}

	public void update(byte in)
	{
		buf[bOff++] = in;
		if (bOff == buf.length)
			processWord(buf, 0);
		byteCount++;
	}

	public void update(byte in[], int inOff, int len)
	{
		for (; bOff != 0 && len > 0; len--)
		{
			update(in[inOff]);
			inOff++;
		}

		while (len > 8) 
		{
			processWord(in, inOff);
			inOff += 8;
			len -= 8;
			byteCount += 8L;
		}
		for (; len > 0; len--)
		{
			update(in[inOff]);
			inOff++;
		}

	}

	private void roundABC(long x, long mul)
	{
		c ^= x;
		a -= t1[(int)c & 0xff] ^ t2[(int)(c >> 16) & 0xff] ^ t3[(int)(c >> 32) & 0xff] ^ t4[(int)(c >> 48) & 0xff];
		b += t4[(int)(c >> 8) & 0xff] ^ t3[(int)(c >> 24) & 0xff] ^ t2[(int)(c >> 40) & 0xff] ^ t1[(int)(c >> 56) & 0xff];
		b *= mul;
	}

	private void roundBCA(long x, long mul)
	{
		a ^= x;
		b -= t1[(int)a & 0xff] ^ t2[(int)(a >> 16) & 0xff] ^ t3[(int)(a >> 32) & 0xff] ^ t4[(int)(a >> 48) & 0xff];
		c += t4[(int)(a >> 8) & 0xff] ^ t3[(int)(a >> 24) & 0xff] ^ t2[(int)(a >> 40) & 0xff] ^ t1[(int)(a >> 56) & 0xff];
		c *= mul;
	}

	private void roundCAB(long x, long mul)
	{
		b ^= x;
		c -= t1[(int)b & 0xff] ^ t2[(int)(b >> 16) & 0xff] ^ t3[(int)(b >> 32) & 0xff] ^ t4[(int)(b >> 48) & 0xff];
		a += t4[(int)(b >> 8) & 0xff] ^ t3[(int)(b >> 24) & 0xff] ^ t2[(int)(b >> 40) & 0xff] ^ t1[(int)(b >> 56) & 0xff];
		a *= mul;
	}

	private void keySchedule()
	{
		x[0] -= x[7] ^ 0xa5a5a5a5a5a5a5a5L;
		x[1] ^= x[0];
		x[2] += x[1];
		x[3] -= x[2] ^ ~x[1] << 19;
		x[4] ^= x[3];
		x[5] += x[4];
		x[6] -= x[5] ^ ~x[4] >>> 23;
		x[7] ^= x[6];
		x[0] += x[7];
		x[1] -= x[0] ^ ~x[7] << 19;
		x[2] ^= x[1];
		x[3] += x[2];
		x[4] -= x[3] ^ ~x[2] >>> 23;
		x[5] ^= x[4];
		x[6] += x[5];
		x[7] -= x[6] ^ 0x123456789abcdefL;
	}

	private void processBlock()
	{
		long aa = a;
		long bb = b;
		long cc = c;
		roundABC(x[0], 5L);
		roundBCA(x[1], 5L);
		roundCAB(x[2], 5L);
		roundABC(x[3], 5L);
		roundBCA(x[4], 5L);
		roundCAB(x[5], 5L);
		roundABC(x[6], 5L);
		roundBCA(x[7], 5L);
		keySchedule();
		roundCAB(x[0], 7L);
		roundABC(x[1], 7L);
		roundBCA(x[2], 7L);
		roundCAB(x[3], 7L);
		roundABC(x[4], 7L);
		roundBCA(x[5], 7L);
		roundCAB(x[6], 7L);
		roundABC(x[7], 7L);
		keySchedule();
		roundBCA(x[0], 9L);
		roundCAB(x[1], 9L);
		roundABC(x[2], 9L);
		roundBCA(x[3], 9L);
		roundCAB(x[4], 9L);
		roundABC(x[5], 9L);
		roundBCA(x[6], 9L);
		roundCAB(x[7], 9L);
		a ^= aa;
		b -= bb;
		c += cc;
		xOff = 0;
		for (int i = 0; i != x.length; i++)
			x[i] = 0L;

	}

	public void unpackWord(long r, byte out[], int outOff)
	{
		out[outOff + 7] = (byte)(int)(r >> 56);
		out[outOff + 6] = (byte)(int)(r >> 48);
		out[outOff + 5] = (byte)(int)(r >> 40);
		out[outOff + 4] = (byte)(int)(r >> 32);
		out[outOff + 3] = (byte)(int)(r >> 24);
		out[outOff + 2] = (byte)(int)(r >> 16);
		out[outOff + 1] = (byte)(int)(r >> 8);
		out[outOff] = (byte)(int)r;
	}

	private void processLength(long bitLength)
	{
		x[7] = bitLength;
	}

	private void finish()
	{
		long bitLength = byteCount << 3;
		update((byte)1);
		while (bOff != 0) 
			update((byte)0);
		processLength(bitLength);
		processBlock();
	}

	public int doFinal(byte out[], int outOff)
	{
		finish();
		unpackWord(a, out, outOff);
		unpackWord(b, out, outOff + 8);
		unpackWord(c, out, outOff + 16);
		reset();
		return 24;
	}

	public void reset()
	{
		a = 0x123456789abcdefL;
		b = 0xfedcba9876543210L;
		c = 0xf096a5b4c3b2e187L;
		xOff = 0;
		for (int i = 0; i != x.length; i++)
			x[i] = 0L;

		bOff = 0;
		for (int i = 0; i != buf.length; i++)
			buf[i] = 0;

		byteCount = 0L;
	}

}

⌨️ 快捷键说明

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