用户期望和 unicode 规范化

发布于 2024-10-21 19:51:02 字数 264 浏览 1 评论 0原文

这是一个有点软的问题,请随时告诉我是否有更好的地方。

我正在开发一些接受需要国际字符的密码的代码 - 因此我需要将输入的 unicode 字符串与存储的 unicode 字符串进行比较。很容易。

我的问题是 - 国际字符集的用户通常期望在这种情况下标准化吗?我的 Google 搜索显示,从“总是这样做”(http://unicode.org/faq/normalization.html) 到“别打扰”之间存在一些意见冲突。不正常化有什么优点/缺点吗? (即,不太可能猜测密码等)

This is a bit of a soft question, feel free to let me know if there's a better place for this.

I'm developing some code that accepts a password that requires international characters - so I'll need to compare an input unicode string with a stored unicode string. Easy enough.

My question is this - do users of international character sets generally expect normalization in such a case? My Google searches show some conflicts in opinion from 'always do it' (http://unicode.org/faq/normalization.html) to 'don't bother'. Are there any pros/cons to not normalizing? (i.e., less likely to able guess a password, etc.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风启觞 2024-10-28 19:51:02

我建议,如果您的密码字段接受 Unicode 输入(大概是 UTF-8 或 UTF-16),请在散列和比较之前对其进行规范化。如果您没有对其进行标准化,并且人们从不同的系统(不同的操作系统,或者不同的浏览器,如果它是网络应用程序,或者具有不同的区域设置)访问它,那么您可能会得到用不同的标准化表示的相同密码。这意味着您的用户将输入正确的密码,但密码被拒绝,并且原因并不明显,他们也没有任何方法可以修复它。

I would recommend that if your password field accepts Unicode input (presumably UTF-8 or UTF-16), that you normalize it before hashing and comparing. If you don't normalize it, and people access it from different systems (different operating systems, or different browsers if it's a web app, or with different locales), then you may get the same password represented with different normalization. This would mean that your user would type the correct password, but have it rejected, and it would not be obvious why, nor would they have any way to fix it.

心碎的声音 2024-10-28 19:51:02

我不会打扰有几个原因:

  1. 你会让事情变得不那么安全。如果两个或多个字符在数据库中都表示为同一事物,则意味着该站点可能的密码较少。 (尽管这可能不是什么大问题,因为可能的密码数量相当大。)
  2. 您将在程序中构建代码来完成复杂的工作,这些工作(可能)是您没有编写的库的一部分。 .最终有人将无法登录。我认为最好让事情保持简单,并相信使用不同字符集的人知道如何正确输入它们。也就是说,我从未以国际密码形式实现过此功能,因此我无法告诉您标准设计模式是什么。

I wouldn't bother for a couple reasons:

  1. You're going to make things less secure. If two or more characters are all represented in your DB as the same thing, then that means there are fewer possible passwords for the site. (Though this probably isn't a huge deal, since the number of possible passwords is pretty huge.)
  2. You will be building code into your program that does complicated work that is (probably) part of a library you didn't write...and eventually somebody won't be able to log in as a result. Better in my mind to keep things simple, and to trust that people using different character sets know how to type them properly. That said, I've never implemented this in an international password form, so I couldn't tell you what the standard design pattern is.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文