HMACSHA256 Class

https://msdn.microsoft.com/en-us/library/system.security.cryptography.hmacsha256(v=vs.110).aspx

Computes a Hash-based Message Authentication Code (HMAC) by using the SHA256 hash function.

Remarks

HMACSHA256 is a type of keyed hash algorithm that is constructed from the SHA-256 hash function and used as a Hash-based Message Authentication Code (HMAC).

The HMAC process mixes a secret key with the message data, hashes the result with the hash function, mixes that hash value with the secret key again, and then applies the hash function a second time.

The output hash is 256 bits in length.

 

An HMAC can be used to determine whether a message sent over an insecure channel has been tampered篡改 with, provided that the sender and receiver share a secret key.

The sender computes the hash value for the original data and sends both the original data and hash value as a single message.

The receiver recalculates the hash value on the received message and checks that the computed HMAC matches the transmitted HMAC.

 

Any change to the data or the hash value results in a mismatch, because knowledge of the secret key is required to change the message and reproduce the correct hash value.

Therefore, if the original and computed hash values match, the message is authenticated.

 

HMACSHA256 accepts keys of any size, and produces a hash sequence 256 bits in length.

=================================================

 

 

属性

Key,从父类继承的

Gets or sets the key to use in the hash algorithm.

public override byte[] Key { get; set; }

 

This property is the key for the keyed hash algorithm.

 

A Hash-based Message Authentication Code (HMAC) can be used to determine whether a message sent over an insecure channel has been tampered with, provided that the sender and receiver share a secret key.

The sender computes the hash value for the original data and sends both the original data and the HMAC as a single message.

The receiver recomputes the hash value on the received message and checks that the computed hash value matches the transmitted hash value.

 

HMAC can be used with any iterative cryptographic hash function, such as MD5 or SHA-1, in combination with a secret shared key.

The cryptographic strength of HMAC depends on the properties of the underlying hash function.

 

Any change to the data or the hash value results in a mismatch, because knowledge of the secret key is required to change the message and reproduce the correct hash value.

Therefore, if the original and computed hash values match, the message is authenticated.

 

实际使用https://github.com/chucklu/Tools/blob/master/Encryptor/FormHMACSHA256.cs

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值