📄 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 + -