Payment micro-channel version C # MD5 signature algorithm, ASCII code lexicographic ordering 0, A, B, a, b

        ///  <Summary> 
        /// micro-channel payment MD5 signature algorithm, ASCII code lexicographic ordering 0, A, B, A, B
         ///  </ Summary> 
        ///  <param name = "indict"> be signed name key-value pair </ param> 
        ///  <param name = "TenPayV3_Key"> Key for signature </ param> 
        ///  <Returns> the MD5 signature string </ Returns> 
        public  static  string WePaySign (the IDictionary < string , String > indict, String TenPayV3_Key) 
        { 
            String [] = arrKeys InDict.Keys.ToArray (); 
            Array.Sort (arrKeys, String .CompareOrdinal);  //ASCII code parameter name in ascending order; 0, A, B, A, B; 

            var StrA = new new the StringBuilder (); 

            the foreach ( var Key in arrKeys) 
            { 
                String value = indict [Key]; 
                 IF (String.IsNullOrEmpty (! value)) // null value is not involved in the signature 
                { 
                    StrA.Append (Key + " = " ) 
                       .Append the (value + " & " ); 
                } 
            } 
            
            // the foreach (var InDict.OrderBy in Item (X => x.Key )) //Parameter name lexicographic; 0, A, A, B, B;
             // {
             //     (! String.IsNullOrEmpty (item.Value)) IF // null value is not involved in signature
             //     {
             //         StrA.Append (Item. + key "=")
             //            .Append the (item.Value + "&");
             //     }
             // } 

            StrA.Append ( " key = " ; + TenPayV3_Key) // NOTE: key to the merchant platform key Key 
            return StrFormat.GetMd5Hash (StrA.ToString ()) the ToUpper ();. 
        }

 

Guess you like

Origin www.cnblogs.com/jopny/p/11454934.html