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
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With