为了账号安全,请及时绑定邮箱和手机立即绑定

How to write the follow simple sha1Hex() in C#(.net) ?

How to write the follow simple sha1Hex() in C#(.net) ?

Smart猫小萌 2019-04-14 11:19:39
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();}
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 439 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号