字符串的 SHA1 是否总是返回 ASCII 字符? [英] Do the SHA1 of a string always return ASCII characters?

查看:67
本文介绍了字符串的 SHA1 是否总是返回 ASCII 字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

输入字符串可以是unicode字符串,计算SHA1后的输出字符串会不会一直返回ASCII字符?

The input string can be a unicode string.Do the output string after calculating SHA1 will always return ASCII characters?

推荐答案

视情况而定,但严格来说,不是.SHA-1 散列的输出是 160 位,或 20 个字节,但不保证字节在 ASCII 范围内.

It depends but strictly speaking, no. The output of the SHA-1 hash is 160 bits, or 20 bytes, but the bytes are not guaranteed to be in the ASCII range.

然而,一些散列函数输出 20 个字节的十六进制等效值(即 40 个字符),因此如果实际散列的前三个字节是 0x7e、0x03 和 0xb2,则输出将以7e03b2"开头,在在这种情况下,输出 ASCII.

However, some hash functions output the hex equivalent (i.e. 40 characters) of the 20 bytes, so if the first three bytes of the actual hash are 0x7e, 0x03, and 0xb2, the output would begin with "7e03b2", in which case the output is ASCII.

这篇关于字符串的 SHA1 是否总是返回 ASCII 字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆