📄 deskey.java
字号:
package au.net.aba.crypto.provider;
/*
* $Id: DESKey.java,v 1.11 1998/10/27 05:10:55 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/DESKey.java,v $
* $Revision: 1.11 $
* $Date: 1998/10/27 05:10:55 $
* $State: Exp $
*/
import java.io.*;
import javax.crypto.SecretKey;
import javax.crypto.spec.DESKeySpec;
/**
* a class that provides a basic DES key.
*/
public class DESKey implements SecretKey, Externalizable
{
public final static String ident = "$Id: DESKey.java,v 1.11 1998/10/27 05:10:55 leachbj Exp $";
static final long serialVersionUID = 1L;
private byte[] key;
/**
* constructor for serialisation
*/
public DESKey()
{
}
/**
* standard constructor.
*
* @param rawKey the byte array containing the raw key data.
*/
public DESKey(
byte[] rawKey)
{
key = new byte[DESKeySpec.DES_KEY_LEN];
System.arraycopy(rawKey, 0, key, 0, DESKeySpec.DES_KEY_LEN);
}
/**
* returns the algorithm for this key.
*
* @return the string "DES"
*/
public String getAlgorithm()
{
return "DES";
}
/**
* returns an encoded representation of this key.
*
* @return the key as raw byte data.
*/
public byte[] getEncoded()
{
byte[] tmp;
tmp = new byte[DESKeySpec.DES_KEY_LEN];
System.arraycopy(key, 0, tmp, 0, DESKeySpec.DES_KEY_LEN);
return tmp;
}
/**
* returns the format for this key.
*
* @return 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 + -