Reputation: 4850
I have had a requirement handed to me to modify an existing application to compute the SHA256 hash of a message body (basically a large string) using a specific key (the key to be provided in the message header).
However in none of the .Net SHA256 classes (eg System.Security.Cryptography.SHA256Managed) can I find a reference to a Key property or anything like that.
Does anyone know how to do this in .Net? (This ideally has to be .Net3.5, which the application targets.)
TIA
Upvotes: 7
Views: 14836
Reputation: 447
You've been asked to compute the Hash-based Message Authentication Code (HMAC) with SHA256. For this you will want to use the HMACSHA256 class - the documentation also includes an example of how to implement this.
Upvotes: 8
Reputation: 6563
There is no key for SHA256. It is hash function and returns the same value each time for the same input. This is not encryption with key.
Upvotes: 1