mirror of
https://gitee.com/freshday/radar.git
synced 2026-03-22 04:37:16 +08:00
opts: change hashcode to md5.
feihu wang
This commit is contained in:
@@ -12,17 +12,17 @@ import java.security.SecureRandom;
|
||||
public class CryptUtils {
|
||||
|
||||
private final static String DES = "DES";
|
||||
//private final static String MD5 = "MD5";
|
||||
private final static String MD5 = "MD5";
|
||||
private final static String SHA = "SHA1";
|
||||
|
||||
public static void main(String args[]){
|
||||
// System.out.println( md5("123") );
|
||||
System.out.println( md5("123") );
|
||||
System.out.println( sha("222222") );
|
||||
}
|
||||
//
|
||||
// public static String md5(String source) {
|
||||
// return encryption(source, MD5);
|
||||
// }
|
||||
|
||||
public static String md5(String source) {
|
||||
return encryption(source, MD5);
|
||||
}
|
||||
|
||||
public static String sha(String source) {
|
||||
return encryption(source, SHA);
|
||||
|
||||
@@ -29,12 +29,12 @@ public class GroovyScriptUtil {
|
||||
* 2016年8月2日
|
||||
*/
|
||||
public static GroovyObject loadScript(String script) {
|
||||
GroovyObject groovyObject = passedClassMap.get(script.hashCode() + "");
|
||||
GroovyObject groovyObject = passedClassMap.get(CryptUtils.md5(script));
|
||||
if (groovyObject == null) {
|
||||
Class groovyClass = groovyClassLoader.parseClass(script);
|
||||
try {
|
||||
groovyObject = (GroovyObject) groovyClass.newInstance();
|
||||
passedClassMap.put(script.hashCode() + "", groovyObject);
|
||||
passedClassMap.put(CryptUtils.md5(script), groovyObject);
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
@@ -62,6 +62,6 @@ public class GroovyScriptUtil {
|
||||
* 删除不在使用的脚本关联的groovy object, 不然内存有溢出风险。
|
||||
*/
|
||||
public static void removeInactiveScript(String script){
|
||||
passedClassMap.remove(script.hashCode() + "");
|
||||
passedClassMap.remove(CryptUtils.md5(script));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user