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

HMACSHA256 Class的更多相关文章

  1. HMAC-SHA256 签名方法各个语音的实现方式之前端JavaScriptes6

    sha256和16进制输出,网上很多种后端的验证方法,几乎没有前端的,所以自己写了个,希望给类似需求的人一个帮助,适用场景 腾讯云接口鉴权 v3签名 npm install sha256npm ins ...

  2. 微信小程序 HMACSHA256 哈希加密

    下载CryptoJS, 增加红色的这句 module.exports = CryptoJS /* CryptoJS code.google.com/p/crypto-js (c) 2009-2012 ...

  3. 对接微信支付使用HMAC-SHA256使用签名算法实现方式

    最近做微信押金支付对接,很多坑,心累!这里提醒一下各位: 首先,确保自己商户号进了白名单,没有需要联系客服,否则接口是调不通的,会一直提示参数错误 其次,确保接口文档是最新的,最好去官网去看,否则可能 ...

  4. python接口自动化22-签名(signature)鉴权(authentication)之加密(HEX、MD5、HMAC-SHA256)

    前言 开放的接口为了避免被别人乱调用,浪费服务器资源,这就涉及到签名(Signature)加密了 API 使用签名方法(Signature)对接口进行鉴权(Authentication).每一次请求都 ...

  5. Java算法HmacSHA256不可用 - Java Algorithm HmacSHA256 not available

    发布的jar包,运行后发现报错 Java Algorithm HmacSHA256 not available 百般思索,发现原生JAR包问题 解决办法: Copy sunjce_provider.j ...

  6. JWT & HMAC-SHA256

    JWT JSON Web Tokens https://jwt.io/ https://en.wikipedia.org/wiki/JSON_Web_Token#Structure HMACSHA25 ...

  7. Md5与HMAC-SHA256

    Md5签名算法 private string CalMd5(string str) { var md5 = MD5.Create(); var bs = md5.ComputeHash(Encodin ...

  8. 微信两种签名算法MD5和HMAC-SHA256

    在做微信接口开发的过程中, 有时候发现会提示签名校验失败, 一模一样的签名逻辑就是有些接口跑步通, 找了一圈发现挺坑的; 原来是有些接口的signType签名类型有区别, 有些接口signType要求 ...

  9. jmeter通过BeanShell,实现对接口参数HmacSHA256加密(转)

    jmeter通过BeanShell,实现对接口参数HmacSHA256加密2019-04-29 05:10 ps. 最近抓包网站的登陆请求,发现就2个参数,用户名和密码,通过工具去请求这个接口,一直返 ...

随机推荐

  1. BZOJ 3325 [SCOI2013]密码 (逆模拟Manacher+构造)

    题目大意:给你一个字符串每个位置和相邻两个位置为回文中心的最长回文串长度,让你构造一个合法的字典序最小的字符串 挺有意思的构造题 首先按照$Manacher$的思想还原$p$数组 定义$f_{ij}$ ...

  2. makefile--回顾基础篇

    前阵子让写makefile,纠结了下,基本忘记差不多了. 1.gcc的编译选项 -c 只是编译不链接,生成目标文件“.o” -S 只是编译不汇编,生成汇编代码 -E 只进行预编译,不做其他处理 -g ...

  3. Vue内置指令

    v-text 类型: string用法: 更新元素的 textContent.如果要更新部分的 textContent ,需要使用 {{ Mustache }} 插值. v-html 类型: stri ...

  4. pandas 8 画图

    from __future__ import print_function import pandas as pd import numpy as np import matplotlib.pyplo ...

  5. python基础7(函数 Ⅱ)

    1.python代码运行遇到函数时 从python解释器开始执行之后,就在内存中开辟了一个空间 每当遇到一个变量的时候,就把变量名和值之间的对应关系记录下来. 但是当遇到函数定义的时候解释器只是象征性 ...

  6. 使用Openfire和Asmack实现IM功能,常常出现“Thread already started”的错误

    近期使用Openfire和Asmack实现Android端的IM功能,可是实际使用的过程中,常常出现"java.lang.IllegalThreadStateException:Thread ...

  7. php函数in_array奇怪现象

    $k = 0; $fieldArr = array('tt', 'bb'); if ( in_array( $k, $fieldArr)) { echo '1'; } 按理来说,是不会输出1的,可是最 ...

  8. poj--1703--Find them, Catch them(并查集巧用)

    Find them, Catch them Time Limit: 1000MS   Memory Limit: 10000KB   64bit IO Format: %I64d & %I64 ...

  9. IE9+ BUG汇总

    CSS透明没有继承 css opacity is not inherited in internet explorer 今儿遇到一个问题源于同事写的一个页面,发现父级明明 opacity:0 了,但子 ...

  10. iOS菜鸟成长笔记(3)——斯坦福公开课学习(1)

    一.iOS四层结构 1.Core OS 是用FreeBSD和Mach所改写的Darwin, 是开源.符合POSIX标准的一个Unix核心.这一层包含或者说是提供了整个iPhone OS的一些基础功能, ...