开发者

what's the byte length for HMAC-SHA-1 signature?

I am wondeirng what's the output length for HMAC-S开发者_开发技巧HA-1 alogorthm? if using Base64 encoding, what's the final length?


20 raw bytes, so ceil(20/3)*4 = 28 bytes as base64.


The result of any HMAC is the output from the choosen digest:

To compute HMAC over the data `text' we perform

               H(K XOR opad, H(K XOR ipad, text))

Where you want H to be SHA-1. So the length of a HMAC-SHA-1 is the same as the length of a SHA-1 that is 160 bits or 20 bytes.

The Base64 encoding expands groups of 3 bytes into 4. So the resulting size will be ceiling(20/3)×4 = 28 characters. Also note that due to padding the last character will always be "=".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜