Howtowritethefollowsimplesha1Hex(sbyte[]data,stringkey)inC#(.net)?下面是Java的代碼,c#要怎么寫這個簡單的算法,要帶key的。publicstaticstringsha1Hex(sbyte[]data,stringkey){sbyte[]keyBytes=key.GetBytes();SecretKeySpecsigningKey=newSecretKeySpec(keyBytes,"HmacSHA1");Macmac;StringBuildersb=newStringBuilder();try{mac=Mac.getInstance("HmacSHA1");mac.init(signingKey);sbyte[]rawHmac=mac.doFinal(data);foreach(sbytebinrawHmac){sb.Append(byteToHexString(b));}}catch(Exception){}returnsb.ToString();}
How to write the follow simple sha1Hex() in C#(.net) ?
Smart貓小萌
2019-04-14 11:19:39