我应该在数据库中保留多少个字符来存储 SHA512 哈希值?
列:pwdhash
类型:char
许多网页给出的是位大小,而不是字符大小。 我应该使用二进制字段吗?
Column: pwdhash
Type: char
Many web pages give me the bit size, not a character size.
Should I use a binary field instead?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
存储在 BLOB 中时64 字节。
以十六进制存储时128 个字符。
~88 个字符(存储为 Base64 时)。
64 bytes when stored in BLOB.
128 characters when stored as hex.
~88 characters when stored as Base64.
是的,您应该使用二进制字段。
哈希不是字符串。
Yes, you should use a binary field.
A hash is not a string.
出于可读性原因,有时将它们存储为十六进制数字(每个字节两位数字)。因此 512 位需要 64 个字节,这需要一个 char(128) 字段。如果使用二进制字段,则只需要 64 个字节。
For readability reasons, these are sometimes stored as hexadecimal digits (two digits per byte). So 512 bits requires 64 bytes, which would need a
char(128)
field. If you used a binary field, it would only need 64 bytes.