📄 rc4key.java
字号:
package au.net.aba.crypto.provider;
/*
* $Id: RC4Key.java,v 1.11 1998/10/27 05:11:01 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/RC4Key.java,v $
* $Revision: 1.11 $
* $Date: 1998/10/27 05:11:01 $
* $State: Exp $
*/
import java.io.*;
import javax.crypto.SecretKey;
/**
* A class wrapper for RC4 keys.
*/
public class RC4Key implements SecretKey, Externalizable
{
public final static String ident = "$Id: RC4Key.java,v 1.11 1998/10/27 05:11:01 leachbj Exp $";
static final long serialVersionUID = 1L;
//==================================
// Constructors
//==================================
private byte[] key;
/**
* Construct an empty RC4Key.
*/
public RC4Key()
{
}
/**
* Construct an RC4Key from a set of bytes.
*
* @param b The data bytes.
*/
public RC4Key(
byte[] b)
{
key = new byte[b.length];
System.arraycopy(b, 0, key, 0, b.length);
}
/**
* return algorithm this key is for.
*
* @param the string "RC4".
*/
public String getAlgorithm()
{
return "RC4";
}
/**
* return an encoded representation of the 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;
}
/**
* return the format this key is in.
*
* @param the string "RAW".
*/
public String getFormat()
{
return "RAW";
}
/**
* serialisation support using Externalizable.
*
* @param in the object input stream.
*/
public void readExternal(
ObjectInput in)
throws IOException
{
int len;
len = in.read();
key = new byte[len];
in.readFully(key, 0, len);
}
/**
* serialisation support using Externalizable.
*
* @param out the object output stream.
*/
public void writeExternal(
ObjectOutput out)
throws IOException
{
out.write((byte)key.length);
out.write(key);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -