This example for you to share the Android micro-credit payment to obtain two signed sign method for your reference, the specific content as follows
/** * Get Sign Signature * * @return/private String Genpayreq () {//Get the value of the parameter payreq request = new Payreq ();
Request.appid = constantsmember.app_id;
Request.partnerid = Constantsmember.mchid;
Request.prepayid = Mprepayid;
Request.packagevalue = "Sign=wxpay";
Request.noncestr = Datautil.getguid ();
Request.timestamp = Datautil.gettimestamp ();
Pass the value of the parameter into the SortedMap set sortedmap<object, object> parameters = new Treemap<object, object> (); {APPID=WX34DF375D7DAE8C90, NONCESTR=3BF34EF2CA4A462DB8D4EA48E785CDC3,//Package=sign=wxpay, partnerid= 1349967601,//prepayid=wx2016070910354542c7155d4e0846850809, timestamp=1468031760} parameters.put ("AppID", request
. appId);
Parameters.put ("Noncestr", request.noncestr);
Parameters.put ("package", request.packagevalue);
Parameters.put ("Partnerid", Request.partnerid);
Parameters.put ("Prepayid", Request.prepayid);
Parameters.put ("timestamp", request.timestamp); String characterencoding = "UTF-8";
String mysign = createsign (characterencoding, parameters);
System.out.println ("My signature is:" + mysign);
return mysign; /** * Micro-credit Payment Signature Algorithm sign * * @param characterencoding * @param parameters * @return */public static String CR Eatesign (String characterencoding, sortedmap<object, object> parameters) {StringBuffer sb = new StringBuffer (
);
Set es = Parameters.entryset ();//All parameters participating in the argument are sorted by accsii (ascending) Iterator it = Es.iterator ();
while (It.hasnext ()) {@SuppressWarnings ("rawtypes") map.entry Entry = (map.entry) it.next ();
String k = (string) entry.getkey ();
Object v = entry.getvalue (); if (null!= v &&! "". Equals (v) &&! " Sign ". Equals (k) &&!"
Key ". Equals (k)) {Sb.append (k +" = "+ V +" & "); } sb.append ("key=" + Constantsmember.key);
Key is the merchant secret key String sign = Md5util.md5encode (Sb.tostring (), characterencoding). toUpperCase (); return sign; d3a5d13e7838e1d453f4f2ea526c4766//d3a5d13e7838e1d453f4f2ea526c4766}
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.