创建随机哈希/字符串的最佳方法是什么? [英] What is the best way to create a random hash/string?

查看:43
本文介绍了创建随机哈希/字符串的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了存储会话而生成哈希的最佳方法是什么?我正在寻找一种轻便、便携的解决方案.

What is the best way of generating a hash for the purpose of storing a session? I am looking for a lightweight, portable solution.

推荐答案

您可以使用 PHP 的内置散列函数,sha1md5.选择一个,而不是两个.

You can use PHP's built-in hashing functions, sha1 and md5. Choose one, not both.

人们可能认为同时使用两者,sha1(md5($pass)) 将是一个解决方案.使用两者不会使您的密码更安全,它会导致冗余数据并且没有多大意义.

One may think that using both, sha1(md5($pass)) would be a solution. Using both does not make your password more secure, its causes redundant data and does not make much sense.

查看PHP 安全联盟:密码哈希 他们给出了一篇很好的文章,指出了弱点并通过散列提高了安全性.

Take a look at PHP Security Consortium: Password Hashing they give a good article with weaknesses and improving security with hashing.

Nonce 代表n一次使用的数字".它们用于请求以防止未经授权的访问,它们发送秘密密钥并在每次使用您的代码时检查密钥.

Nonce stands for "numbers used once". They are used on requests to prevent unauthorized access, they send a secret key and check the key each time your code is used.

您可以在 FullThrottle Development 的 PHP NONCE 库中查看更多信息

You can check out more at PHP NONCE Library from FullThrottle Development

这篇关于创建随机哈希/字符串的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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