?? ciphertool.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 + -