下边这个函数有什么作用?(J2ME下运行的!)

[复制链接]
查看11 | 回复1 | 2010-6-3 12:02:18 | 显示全部楼层 |阅读模式
public static String strToDes(String strData1,String strKey1){
int bytelen1 = strData1.getBytes().length;

byte[] result1 = new byte[(bytelen1 + 8) - (bytelen1 % 8)];
byte[] bytekey1 = strKey1.getBytes();
byte[] bytedata1 = strData1.getBytes();
String strEjz01,strSLjz01;
String strSLjz02 = "";
DES des001 = new DES();
result1 = des001.DesEncrypt(bytekey1, bytedata1, 1);//加密函数
for(int i01 = 0;i01 < result1.length;i01++){

strEjz01 = Integer.toBinaryString(Math.abs(result1[i01]));

strEjz01 = "00000000" + strEjz01;

strEjz01 = strEjz01.substring(strEjz01.length()-7, strEjz01.length());

if(result1[i01]<0){

strEjz01 = "1" + strEjz01;

}

else{

strEjz01 = "0" + strEjz01;

}

strSLjz01 = Integer.toHexString(Integer.parseInt(Integer.valueOf(strEjz01,2).toString()));//整数到十六进制数

strSLjz01 = "00" + strSLjz01;

strSLjz01 = strSLjz01.substring(strSLjz01.length()-2,strSLjz01.length());

strSLjz02 = strSLjz02 + strSLjz01;
}
String result001 = strSLjz02.toUpperCase();
return result001;
}

回复

使用道具 举报

千问 | 2010-6-3 12:02:18 | 显示全部楼层
看样子是把一个字符串用DES加密算法加密的
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行