简体   繁体   中英

What is the c# equivalent for progressive HMACSHA256?

In Java we have progressive hmac like so:

Mac mac = Mac.getInstance("HmacSHA256");
mac.init(macKey);
mac.update(part(0));
mac.update(part(1));
...
byte[] fullMac = mac.doFinal(part(n))

Please what is the c# equivalent for progressive HMACSHA256?

Got it! Microsoft over-cooked the otherwise simple Update operation into TransformBlock & TransformFinalBlock

Mac mac = Mac.getInstance("HmacSHA256");
mac.init(macKey);
mac.update(part(0));
mac.update(part(1));
...
byte[] fullMac = mac.doFinal(part(9))

in .Net this now becomes (vb.net)

dim fullMac as byte()
using mac=New HMACSHA256(macKey)
   mac.TransformBlock(part(0),0,part(0).Length,null,0)
   mac.TransformBlock(part(1),0,part(1).Length,null,0)
   ...
   fullMac=mac.TransformFinalBlock(part(9),0,part(9).Length)
end using

I don't see how this helps developer-productivity in any way :(

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM