streamblockcipher.java

来自「java 文件下载器。可自定义」· Java 代码 · 共 64 行

JAVA
64
字号
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   StreamBlockCipher.java

package org.bouncycastle.crypto;


// Referenced classes of package org.bouncycastle.crypto:
//			BlockCipher, DataLengthException, StreamCipher, CipherParameters

public class StreamBlockCipher
	implements StreamCipher
{

	private BlockCipher cipher;
	private byte oneByte[];

	public StreamBlockCipher(BlockCipher cipher)
	{
		oneByte = new byte[1];
		if (cipher.getBlockSize() != 1)
		{
			throw new IllegalArgumentException("block cipher block size != 1.");
		} else
		{
			this.cipher = cipher;
			return;
		}
	}

	public void init(boolean forEncryption, CipherParameters params)
	{
		cipher.init(forEncryption, params);
	}

	public String getAlgorithmName()
	{
		return cipher.getAlgorithmName();
	}

	public byte returnByte(byte in)
	{
		oneByte[0] = in;
		cipher.processBlock(oneByte, 0, oneByte, 0);
		return oneByte[0];
	}

	public void processBytes(byte in[], int inOff, int len, byte out[], int outOff)
		throws DataLengthException
	{
		if (outOff + len > out.length)
			throw new DataLengthException("output buffer too small in processBytes()");
		for (int i = 0; i != len; i++)
			cipher.processBlock(in, inOff + i, out, outOff + i);

	}

	public void reset()
	{
		cipher.reset();
	}
}

⌨️ 快捷键说明

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