<body>
<p>
<%
abc.getKey();
String result=ddd.getdisksn();//通过jni获取的硬盘序列号
String result2="75JO6066S00016CCA8767";
String mi=abc.getEncString(result2);//des加密函数
String mi2=abc.getEncString(result);
%>
</p>
<p>result= <%=result%></p>
<p>result2= <%=result2%></p>
<p>mi= <%=mi%></p>
<p>mi2= <%=mi2%></p>
</body>显示结果:
result= 75JO6066S00016CCA8767result2= 75JO6066S00016CCA8767mi= 6VdCpwOTBuZ7BOdr4t36HQq7pIAkibDvmi2= 1oDXXNbNGEW8wqhK373KWHpcaZBLG78Y9vUueHSmqnZNBJsOY+CFbA==问题:
result应该和result2的值是一样的,为什么加密出来的结果不一样呢?解密时通过abc.getEnsString(result)加密的内容就可以得到75JO6066S00016CCA8767的结果,而通过abc.getEncString("75JO6066S00016CCA8767")加密的就不可以。以下为getEncString函数代码:public String getDesString(String strMi)
{
BASE64Decoder base64De = new BASE64Decoder();
byte[] byteMing = null;
byte[] byteMi = null;
String strMing = "";
try
{
byteMi = base64De.decodeBuffer(strMi);
byteMing = this.getDesCode(byteMi);
strMing = new String(byteMing, "UTF8");
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
base64De = null;
byteMing = null;
byteMi = null;
}
return strMing;
}
<p>
<%
abc.getKey();
String result=ddd.getdisksn();//通过jni获取的硬盘序列号
String result2="75JO6066S00016CCA8767";
String mi=abc.getEncString(result2);//des加密函数
String mi2=abc.getEncString(result);
%>
</p>
<p>result= <%=result%></p>
<p>result2= <%=result2%></p>
<p>mi= <%=mi%></p>
<p>mi2= <%=mi2%></p>
</body>显示结果:
result= 75JO6066S00016CCA8767result2= 75JO6066S00016CCA8767mi= 6VdCpwOTBuZ7BOdr4t36HQq7pIAkibDvmi2= 1oDXXNbNGEW8wqhK373KWHpcaZBLG78Y9vUueHSmqnZNBJsOY+CFbA==问题:
result应该和result2的值是一样的,为什么加密出来的结果不一样呢?解密时通过abc.getEnsString(result)加密的内容就可以得到75JO6066S00016CCA8767的结果,而通过abc.getEncString("75JO6066S00016CCA8767")加密的就不可以。以下为getEncString函数代码:public String getDesString(String strMi)
{
BASE64Decoder base64De = new BASE64Decoder();
byte[] byteMing = null;
byte[] byteMi = null;
String strMing = "";
try
{
byteMi = base64De.decodeBuffer(strMi);
byteMing = this.getDesCode(byteMi);
strMing = new String(byteMing, "UTF8");
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
base64De = null;
byteMing = null;
byteMi = null;
}
return strMing;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货