c# - How to efficiently generate strong ETags using a System.Net.Cryptography HashAlgorithm? -


when handling httprequestmessages in webapi2, we're looking @ multiple ways handle if-none-match using strong etags.

hashing response content strong etag obvious solution needs hashing process scale.

it appears best practice code generating hash like:

using (var hasher = sha1.create())     return hasher.computehash(stream); 

what costs associated creating hashalgorithm object?

is using byte array more efficient stream?

using (var hasher = sha1.create())     return hasher.computehash(bytearray); 

i've encountered info suggesting managed version of algorithms might stateless, possibly allowing computehash called multiple times on same object, makes me wonder if means there no real cost associated creating new object each time.

thanks in advance!


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -