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

📄 twofishkeyspec.java

📁 面向应用的智能安全代理平台和工具包是一个综合网络应用的安全共性需求而设计和实现的一个通用性的网络信息安全应用支撑平台
💻 JAVA
字号:
package au.net.aba.crypto.spec;

/*
 * $Id: TwofishKeySpec.java,v 1.1 1998/10/13 07:57:50 leachbj Exp $
 * $Author: leachbj $
 *
 * Copyright (C) 1996-1998 Australian Business Access Pty Ltd.
 * All rights reserved.
 *
 * Use, modification, copying and distribution of this software is subject the
 * terms and conditions of the ABA Public Licence. See the file
 * "PUBLIC_LICENCE" for additional information.
 *
 * If you have not received a copy of the Public Licence, you must destroy all
 * copies of this file immediately. 
 *
 * $Source: /aba/CVSROOT/jdk1.1/src/au.net.aba/crypto/spec/TwofishKeySpec.java,v $
 * $Revision: 1.1 $
 * $Date: 1998/10/13 07:57:50 $
 * $State: Exp $
 */

import java.security.spec.KeySpec;
import java.security.InvalidKeyException;

/**
 * A class that provides a specification for a Twofish key.  Twofish
 * keys may be 256, 192 or 128 bits long (shorter keys are padded with
 * zeros to next larger size).
 */
public class TwofishKeySpec implements KeySpec
{
	public final static String ident = "$Id: TwofishKeySpec.java,v 1.1 1998/10/13 07:57:50 leachbj Exp $";

	private byte[]	tfKey;

	private static int MAXTFKEY_LENGTH = 32;

	/**
	 * Uses the first 32 bytes (if available) as the key, starting at 0
	 *
	 * @param key	the byte array to use as key material.
	 * @exception InvalidKeyException if the key material is too short.
	 */
	public TwofishKeySpec(
		byte[]	key)
		throws InvalidKeyException
	{
		this(key, 0);
	}
	/**
	 * Uses the first 32 bytes (if available) in key, beginning at offset,
	 * as the Twofish key
	 *
	 * @param key		the byte array to use as key material.
	 * @param offset	the offset to start at.
	 * @exception InvalidKeyException if the key material is too short.
	 */
	public TwofishKeySpec(
		byte[]	key,
		int	offset)
		throws InvalidKeyException
	{
		int a = key.length - offset; // available bytes

		if (a > MAXTFKEY_LENGTH)
		{
			a = MAXTFKEY_LENGTH;
		}
		tfKey = new byte[a];
		System.arraycopy(key, offset, tfKey, 0, a);
	}
	/**
	 * Returns the Twofish key.
	 *
	 * @return the bytes making up the key.
	 */
	public byte[] getKey()
	{
		return tfKey;
	}
}

⌨️ 快捷键说明

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