一个JAVA的程序段
public static boolean InCharge(Integer uid,Double amount,String checkcode)
{
String key = "sing#48fm ";
String tmpstr = uid.toString().concat(((Integer)amount.intValue()).toString()).concat(key);
tmpstr = data.MD5.TOMD5(tmpstr);
if(!tmpstr.equals(checkcode)) return false;
DBAccess myconn = new DBAccess();
int result = 0;
try
{
String str;
str = String.format( "insert into cash_exchange(user_id,cost,director,createtime) values " + "(%d,%s,0,now()) ",
uid,amount);
result = myconn.executeNoneQuerySQL(str);
if(result> 0)
{
str = String.format( "update cdb_members set amount=amount+( "+amount.toString()+ ") where uid=%d ",uid);
result = myconn.executeNoneQuerySQL(str);
}
}
catch(
SQLException e1){
e1.printStackTrace();
}
return result> 0;
=======================================================================
中有一段
String key = "sing#48fm ";
String tmpstr = uid.toString().concat(((Integer)amount.intValue()).toString()).concat(key);
tmpstr = data.MD5.TOMD5(tmpstr);
if(!tmpstr.equals(checkcode)) return false;
我不明白是什么意思.请大侠们告诉我.
------解决方案--------------------传进来的uid是Integer型的,uid.toString()把Uid转成String型,
amount是Double型的,先转成Integer型,然后再用.toString转换
成String型。
concat(String str)意思是将指定字符串联到此字符串的结尾。
最终把传进来的参数和key都拼成一个字符串tmpStr,
然后用data.MD5.TOMD5(String str)对tmpstr进行解密。