?? twofishkey.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 + -