pbekey.java

来自「面向应用的智能安全代理平台和工具包是一个综合网络应用的安全共性需求而设计和实现的」· Java 代码 · 共 87 行

JAVA
87
字号
package au.net.aba.crypto.provider;

/*
 * $Id: PBEKey.java,v 1.2 1999/01/21 01:35:38 wslade Exp $
 * $Author: wslade $
 *
 * 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/PBEKey.java,v $
 * $Revision: 1.2 $
 * $Date: 1999/01/21 01:35:38 $
 * $State: Exp $
 */

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

import javax.crypto.*;
import javax.crypto.spec.PBEKeySpec;

/**
 * A class wrapper for Blowfish keys.
 */
public class PBEKey implements SecretKey
{
	public final static String ident = "$Id: PBEKey.java,v 1.2 1999/01/21 01:35:38 wslade Exp $";

	private char[] pwd;
	
	/**
	 * The basic constructor
	 *
	 *
	 * @param pwd	the bytes making up the key.
	 */
	public PBEKey(
		char[] pwd)
	{
		this.pwd = pwd;
	}
	/**
	 * returns the algorithm for this key.
	 *
	 * @return the string "PBE"
	 */
	public String getAlgorithm()
	{
		return "PBE";
	}
	/**
	 * returns a null since there is no encoded form.
	 *
	 * @return the key as a byte array
	 */
	public byte[] getEncoded()
	{
		return null;
	}
	/**
	 * returns the format for this key.
	 *
	 * @return the string "RAW"
	 */
	public String getFormat()
	{
		return "RAW";
	}
	/**
	 * Returns the password. This method is specific to the PBE implementation
	 **/
	public char[] getPassword()
	{
		char[] cpy = new char[pwd.length];
		System.arraycopy(pwd, 0, cpy, 0, pwd.length);
		return cpy;
	}
}

⌨️ 快捷键说明

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