In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Today, I will talk to you about the example analysis of generating signatures in python. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.
/ get signature / public string Sign (object body) {/ / get all attributes var signKeys = new Dictionary (); GetSignKeys (null, body, signKeys)
Var lstSignKeys = signKeys.ToList (); var indexReg = new System.Text.RegularExpressions.Regex ("\\ [(\\ d)\]"); lstSignKeys.Sort ((v1, v2) = > {var keyRepair1 = indexReg.Replace (v1.Key, "[0 $1]"); var keyRepair2 = indexReg.Replace (v2.Key, "[0 $1]"); return string.CompareOrdinal (keyRepair1, keyRepair2);}) Var signStr = lstSignKeys.Join ("&", t = > $"{t.Key} = {t.Value}"); signStr + = $"& key= {ThirdPlatServiceAPPKey}"; return getSign (signStr, ThirdPlatServiceAPPKey);} public string getSign (string stringSignTemp, string apikey) {string sign = SecurityHelper.MD5Encrypt (stringSignTemp, Encoding.UTF8); sign = SecurityHelper.HMACSHA256Encrypt (sign, apikey, Encoding.UTF8). ToLower (); return sign } private void GetSignKeys (string Key, object obj, Dictionary signKeys) {if (obj = = null) return; if (obj is string & &! string.IsNullOrEmpty (obj.ToString ()) signKeys.Add (Key, obj.ToString ()); else if (obj is double dbl) signKeys.Add (Key, dbl.ToString ("0.00")) Else if (obj is decimal dec) signKeys.Add (Key, dec.ToString ("0.00"); else if (obj.GetType () .IsValueType) signKeys.Add (Key, obj.ToString ()); else if (obj is IList lst) {/ / list object var index =-1; foreach (var item in lst) {index++ GetSignKeys ($"{Key} [{index}]", item, signKeys) }} else {if (! string.IsNullOrEmpty (obj.ToString () {if (string.IsNullOrEmpty (Key)) {foreach (var property in obj.GetType (). GetProperties ()) {GetSignKeys (property.Name) Property.GetValue (obj, null), signKeys) }} else {foreach (var property in obj.GetType (). GetProperties ()) {GetSignKeys (Key + "." + property.Name, property.GetValue (obj, null), signKeys) }} after reading the above, do you have any further understanding of the example analysis of generating signatures in python? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.