⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ciphertool.java

📁 这是一个轻便的j2ee的web应用框架,是一个在多个项目中运用的实际框架,采用struts,hebinate,xml等技术,有丰富的tag,role,navigation,session,dictio
💻 JAVA
字号:
/*
 * Created on 2004-5-11
 *
 */
package com.esimple.service.crypto.cipher;

import com.sun.crypto.provider.SunJCE;
import java.security.Security;
/**
 * @author steven
 *
 */
public class CipherTool {
	static {
		Security.addProvider(new SunJCE());
	}

	public static  String encrypt(String algorithm, String str) throws Exception {
		String result = null;
		Encdec ed = EncdecFactory.getEncdec(algorithm);
		if( ed== null ) throw new Exception("algorithm not support");
		
		result = ed.encrypt(str);
		
		if (result == null)
			throw new Exception("Encrypt string error.");
		else
			return result;
	}

	public static String decrypt(String algorithm,String str) throws Exception {
		String result = null;
		Encdec ed = EncdecFactory.getEncdec(algorithm);
		result = ed.decrypt (str);
		if (result == null)
			throw new Exception("Decrypt string error.");
		else
			return result;
	}
}

⌨️ 快捷键说明

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