📄 rc4keyspec.java
字号:
package au.net.aba.crypto.spec;
/*
* $Id: RC4KeySpec.java,v 1.4 1998/10/05 05:47:56 dgh Exp $
* $Author: dgh $
*
* 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/RC4KeySpec.java,v $
* $Revision: 1.4 $
* $Date: 1998/10/05 05:47:56 $
* $State: Exp $
*/
import java.security.spec.KeySpec;
import java.security.InvalidKeyException;
/**
* A class that provides a specification for a RC4 key.
*/
public class RC4KeySpec implements KeySpec
{
public final static String ident = "$Id: RC4KeySpec.java,v 1.4 1998/10/05 05:47:56 dgh Exp $";
private byte[] rc4Key;
/**
* Uses the first 16 bytes in key as the RC4 key
*
* @param key the bytes making up the key.
* @exception InvalidKeyException if the key material is too short.
*/
public RC4KeySpec(
byte[] key)
throws InvalidKeyException
{
this(key, 0, 16);
}
/**
* Uses the first len bytes in key as the RC4 key
*
* @param key the bytes making up the key.
* @param len the size (in bytes) of the key.
* @exception InvalidKeyException if the key material is too short.
*/
public RC4KeySpec(
byte[] key,
int len)
throws InvalidKeyException
{
this(key, 0, len);
}
/**
* Uses the first len bytes in key, beginning at offset, as the RC4 key
*
* @param key the bytes making up the key.
* @param offset the offset to start copying the key material.
* @param len the size (in bytes) of the key.
* @exception InvalidKeyException if the key material is too short.
*/
public RC4KeySpec(
byte[] key,
int offset,
int len)
throws InvalidKeyException
{
if (key.length - offset < len)
{
throw new InvalidKeyException("Key too short");
}
rc4Key = new byte[len];
System.arraycopy(key, offset, rc4Key, 0, len);
}
/**
* Returns the RC4 key.
*
* @return the bytes making up the key.
*/
public byte[] getKey()
{
return rc4Key;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -