我应该使用 base64 编码将密码存储在数据库表中吗?
我正在使用 PBKDF2 加密来用盐哈希密码。 应用 Base64 编码后,我应该将哈希密码和盐存储在数据库中吗?
如果我确实使用该编码,那么密码长度将从 64 变为 88,这比我不使用它时需要更多的存储空间。
使用编码有哪些优点和缺点?
我也应该将它应用于盐吗?
I am using PBKDF2 encryption to hash password with salt.
should I store hashed password and salt in database after applying base64 encoding?
If I do use the encoding, then the password length becomes 88 from 64, which requires more storage than when I am not using it.
What are advantages and disadvantages for using the encoding?
should I apply it to salts too?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从安全方面来看,存储纯字节和存储它们的 Base64 编码之间没有区别。
如果您存储纯字节,请确保为您的列选择正确的数据类型(例如二进制数据类型,而不是字符数据类型)。如果存储 base64,则可以使用采用 US-ASCII 编码的字符列。
Base64 的优点是人们可以更轻松地查看数据并查看它是否与其他数据相同,但仅此而已 - 您也可以在查询数据后轻松进行编码。
From the security side, there is no difference between storing pure bytes, and storing a Base64-encoding of them.
If you store pure bytes, make sure you select the right datatype (e.g. a binary one, not a character one) for your column. If you store base64, you can use a character column with US-ASCII encoding.
Base64 has the advantage that a human can more easily look at the data and see if it is the same as some other, but this is about it - you could easily do the encoding after querying the data, too.