使用 CreateUUID() 函数作为盐是个好主意吗?

发布于 2024-09-16 14:31:13 字数 186 浏览 5 评论 0原文

我正在使用 Coldfusion,我想为我的密码生成一个随机盐字段。我想知道 CreateUUID() 函数在这里是否有用。我发现很多例子使用单独的函数来创建盐字符串;但是当您可以使用 rand() 或 CreateUUID() 函数时为什么要这样做呢?我不知道。

这是一个矫枉过正还是一个好主意?或者我应该使用 rand() 或时间戳代替?

I'm using coldfusion and I would like to generate a random salt field for my passwords. I was wondering if a CreateUUID() function is useful here. I found many examples which use a seperate function to create the salt string; but why do this when you could use rand() or CreateUUID() functions instead? I'm not sure.

Is it an overkill or a good idea? Or should I use rand() or a timestamp instead?

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

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

发布评论

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

评论(1

旧人 2024-09-23 14:31:13

不是一个好主意 - CreateUUID 保证唯一性,而不是随机性;如果您对 CreateUUID 进行统计分析,它很可能不会被认为是对于密码学而言足够随机的分布,因为它不是以这种方式明确设计的。

例如,CreateUUID 的前 n 字节是您的 MAC 地址 - 即对于每个盐总是相同的。通过这样做,您可以显着减少盐的熵量,从而使它们更容易裂解。如果可能的话,使用库来处理整个身份验证场景,如果不可能,请使用真正的 rand() 函数。

This is not a good idea - CreateUUID guarantees uniqueness, not randomness; if you did a statistical analysis of CreateUUID, it most likely wouldn't be a distribution considered sufficiently random for cryptography, because it wasn't explicitly designed that way.

For example, the first n bytes of CreateUUID is your MAC address - i.e. always the same for every salt. By doing that, you've significantly decreased the amount of entropy that your salts have, thereby making them easier to crack. Use libraries to handle the whole auth scenario if at all possible, and if not, use a real rand() function.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文