admin管理员组

文章数量:1639831

DES类:

public class DESEncrypt {
	
	/** 加密工具 */
	private Cipher encryptCipher = null;

	/** 解密工具 */
	private Cipher decryptCipher = null;

        private void initialize_encryptKey(String keyValue) throws Exception{
	        Key key = getKey(keyValue.getBytes());
		encryptCipher = Cipher.getInstance("DES");
		encryptCipher.init(Cipher.ENCRYPT_MODE, key);
	}

	public void initalize_dencryptkey(String keyValue) throws Exception {
                Key key = getKey(keyValue.getBytes());
		decryptCipher = Cipher.getInstance("DES");
		decryptCipher.init(Cipher.DECRYPT_MODE, key);
	}

	/**
	 * 从指定字符串生成密钥,密钥所需的字节数组长度为8位 不足8位时后面补0,超出8位只取前8位
	 * 
	 * @param arrBTmp
	 *            构成该字符串的字节数组
	 * @return 生成的密钥
	 * @throws java.lang.Exception
	 */
	private Key getKey(byte[] arrBTmp) throws Exception {
		// 创建一个空的8位字节数组(默认值为0)
		byte[] arrB = new byte[8];

		//

本文标签: 加密算法文件Javades