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

📄 cdigest.java

📁 说明: 1、里面有什么: 1.1、org.bouncycastle.*下的所有软件是bouncycastle组织开发的软件包 1.2、org.infosecurity.*下的软件包括
💻 JAVA
字号:
package org.infosecurity.cryptography;import org.infosecurity.cryptography.*;/** * <p>Title: 摘要算法的抽象类 </p> * <p>Description: 摘要算法的抽象类 </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company:bouncycastle org </p> */public abstract class CDigest    implements IDigest{    private byte[]  xBuf;    private int     xBufOff;    private long    byteCount;    // 1.构造	protected CDigest()	{		xBuf = new byte[4];		xBufOff = 0;	}	protected CDigest(CDigest t)	{        xBuf = new byte[t.xBuf.length];		System.arraycopy(t.xBuf, 0, xBuf, 0, t.xBuf.length);		xBufOff = t.xBufOff;		byteCount = t.byteCount;	}    // 2.输入一个字节的数据    public void update(        byte in)    {        xBuf[xBufOff++] = in;        // 填充满一个4个字节了        if (xBufOff == xBuf.length)        {            processWord(xBuf, 0);            xBufOff = 0;        }        byteCount++;    }    public void update(        byte[]  in,        int     inOff,        int     len)    {        //        // fill the current word        //        while ((xBufOff != 0) && (len > 0))        {            update(in[inOff]);            inOff++;            len--;        }        //        // process whole words.        //        while (len > xBuf.length)        {            processWord(in, inOff);            inOff += xBuf.length;            len -= xBuf.length;            byteCount += xBuf.length;        }        //        // load in the remainder.        //        while (len > 0)        {            update(in[inOff]);            inOff++;            len--;        }    }    // 3.完成    public void finish()    {        // 每一个字节是8位        long    bitLength = (byteCount << 3);        //        // 附加填充比特一个1,多个0,直到len mod 512 = 448        //1000,0000B=128        update((byte)128);        while (xBufOff != 0)        {            update((byte)0);        }        // 最后填充8字节(64bit)的长度信息        processLength(bitLength);        // 处理最后一块        processBlock();    }    public void reset()    {        byteCount = 0;        xBufOff = 0;		for ( int i = 0; i < xBuf.length; i++ ) {			xBuf[i] = 0;		}    }    protected abstract void processWord(byte[] in, int inOff);    protected abstract void processLength(long bitLength);    protected abstract void processBlock();}

⌨️ 快捷键说明

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