. Net to achieve the development of micro-credit public service platform certification, certification as a developer, the specific content as follows
These codes are also used once for authentication, and will not be available later:
Const string Token = "XXXXX";//your Token protected void Page_Load (object sender, EventArgs e) {string poststr = ""; if (Request.HttpMethod.ToLower () = = "Post") {System.IO.Stream s = System.Web.HttpContext.Current.Request.Input
Stream;
Byte[] B = new Byte[s.length];
S.read (b, 0, (int) s.length);
Poststr = System.Text.Encoding.UTF8.GetString (b); if (!string.
IsNullOrEmpty (POSTSTR)) {//responsemsg (POSTSTR);
Response.Write (Responsemsg (POSTSTR));
Response.End ();
}//writelog ("Poststr:" + poststr);
else {Valid (); }///<summary>///authentication Micro-letter Signature///</summary>///* token, timestamp, nonce three parameters are sorted in dictionary///* to spell three parameter strings
followed by a string for SHA1 encryption///* The developer obtains the encrypted string to compare with the signature, which identifies the request from the micro-letter. <returns></returns> private bool Checksignature () {String signature = request.querystring["signature "].
ToString (); string timestamp = request.querystring["Timestamp"].
ToString (); String Nonce = request.querystring["Nonce"].
ToString ();
String[] Arrtmp = {Token, timestamp, nonce}; Array.Sort (ARRTMP); Dictionary sort String tmpstr = string.
Join ("", arrtmp);
Tmpstr = FormsAuthentication.HashPasswordForStoringInConfigFile (tmpstr, "SHA1");
Tmpstr = Tmpstr.tolower ();
if (tmpstr = = signature) {return true;
else {return false; }. private void Valid () {String echostr = request.querystring["Echostr"].
ToString (); if (Checksignature ()) {if (!string).
IsNullOrEmpty (ECHOSTR)) {Response.Write (ECHOSTR);
Response.End (); }}///<summary>///write log (for tracking)///</summary> private void Writelog (string strmemo) {Stri
ng filename = Server.MapPath ("/logs/log.txt"); if (!
Directory.Exists (Server.MapPath ("//logs//")) Directory.CreateDirectory ("//logs//");
StreamWriter sr = null; try {if (!
File.exists (filename)) {sr = file.createtext (filename); else {sr = file.appendtext (filename); } Sr.
WriteLine (Strmemo); The catch {} finally {if (SR!= null) Sr.
Close (); }
}
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.