脚本宝典收集整理的这篇文章主要介绍了PHP中的Ruby bcrypt密码检索,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
验证
通过“检索”,我的意思是我需要使用PHP / YII应用程序验证用户登录,以使用Rails应用程序中的bcrypt-ruby创建的密码字段来解释数据库表.
$database_record = "something"; // grab From database $user_input = 'unicorns'; // take real one from post data $password = crypt($user_input,'$2a$10$usesomesillystringforsalt$'); // key piece above is the second number,that is the 'work' factor if (crypt($user_input,$database_record) == $password) { echo "Password verified!"; } else { echo 'Failed!'; }
这假设您使用Ruby中的BCrypt :: Password.create(desired_pass)存储它们,并通过BCrypt :: Password.new(database_entry)== form_input验证登录.
$password = crypt($user_input,’$2a $10 $usesomesillystringforsalt $’);
最后,确保始终使用正确的成本因素.具有不同成本因素的相同密码将不相等. bcrypt-ruby中的默认成本因子是10(当前版本,3.0.1).
以上是脚本宝典为你收集整理的PHP中的Ruby bcrypt密码检索全部内容,希望文章能够帮你解决PHP中的Ruby bcrypt密码检索所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。