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

📄 twofishkey.java

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

/*
 * $Id: TwofishKey.java,v 1.3 1998/10/26 01:46:42 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/provider/TwofishKey.java,v $
 * $Revision: 1.3 $
 * $Date: 1998/10/26 01:46:42 $
 * $State: Exp $
 */

import java.io.*;
import java.security.*;
import java.util.StringTokenizer;

import javax.crypto.*;

/**
 * A class wrapper for Twofish keys.
 */
public class TwofishKey implements SecretKey
{
	public final static String ident = "$Id: TwofishKey.java,v 1.3 1998/10/26 01:46:42 leachbj Exp $";

	private byte[]		key;

	/**
	 * The basic constructor
	 *
	 * Key length is variable up to 256 bits.  (32 bytes)
	 *
	 * @param rawKey	the bytes making up the key.
	 */
	public TwofishKey(
		byte[]	rawKey)
	{
		int keyLength = (rawKey.length + 7) & ~7;	// round up to multiple of 8

		key = new byte[keyLength];

		/*
		 * copy in the provided key bytes
		 */
		System.arraycopy(rawKey, 0, key, 0, rawKey.length);

		/*
		 * zero out the rest of the key
		 */
		for (int i = rawKey.length; i < key.length; i++)
		{
			key[i] = 0;
		}
	}
	/**
	 * returns the algorithm for this key.
	 *
	 * @return the string "Twofish"
	 */
	public String getAlgorithm()
	{
		return "Twofish";
	}
	/**
	 * returns an encoded representation of this key.
	 *
	 * @return the key as a byte array
	 */
	public byte[] getEncoded()
	{
		byte[]	tmp;

		tmp = new byte[key.length];
		System.arraycopy(key, 0, tmp, 0, key.length);

		return tmp;
	}
	/**
	 * returns the format for this key.
	 *
	 * @return the string "RAW"
	 */
	public String getFormat()
	{
		return "RAW";
	}
}

⌨️ 快捷键说明

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