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();}
添加回答
举报
0/150
提交
取消