string data-signature = encrypttomd5string(jsonstr,appkey)
string encrypttomd5string(string content,string appkey)
{
return encrypttomd5string(
stringutils.trim (appkey) stringutils.trim(content));
}
string encrypttomd5string(string content)
{
string md5string = null;
messagedigest md = messagedigest.getinstance("md5");
md.update(content.getbytes("utf-8"));
md5string = parsebyte2hexstring(md.digest());
return md5string;
}
string parsebyte2hexstring(byte buf[])
{
stringbuffer stringbuffer = new stringbuffer();
for (int i = 0; i < buf.length; i )
{
string hex = integer.tohexstring(buf[i] & 0xff);
if (hex.length() == 1) {hex = '0' hex;}
stringbuffer.append(hex.touppercase());
}
return stringbuffer.tostring();
}
|