📄 desutils.java
字号:
/*
* Created on Jun 14, 2005
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package com.set.utils;
import com.set.utils.crypt.Des;
/**
* @author Administrator
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class DesUtils {
public static String Encrypt(String origindata) {
String ret = null;
Des des = new Des();
byte[] data;
data = des.encrypt("utmp", origindata.getBytes());
ret = "";
for (int i = 0; i < data.length; i++) {
String tmp = Integer.toString(data[i] & 0xff, 16);
if (tmp.length() == 1)
tmp = "0" + tmp;
if (tmp.length() == 0)
tmp = "00";
ret = ret + tmp;
}
return ret;
}
public static String Decrypt(String encryptdata) {
String ret = null;
Des des = new Des();
byte[] data = new byte[encryptdata.length() / 2];
int i;
for (i = 0; i * 2 < encryptdata.length(); i++) {
data[i] = (byte) (Integer.parseInt(encryptdata.substring(i + i, i
+ i + 2), 16));
}
// data[i] = (byte)0;
return new String(des.decrypt("utmp", data));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -