如何在 Ruby 中生成随机令牌 [英] HowTo generate Random Token in Ruby

查看:40
本文介绍了如何在 Ruby 中生成随机令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的 rails 应用程序生成唯一 ID.将它们发送给用户.SecureRandom - 支持在 1.9.3 结束.UUIDTool 适用于 Admin-Tooken,但不适用于像 www.site.com/h6scre55x66

I want generate unique ID for my rails-application. To send them to the user. SecureRandom-support ended for 1.9.3. The UUIDTool is good for the Admin-Tooken, but not for a short url-Restful ID like www.site.com/h6scre55x66

Rails 是否有 SecureRandom 的替代方案?

Is there an alternative for rails to SecureRandom?

谢谢

推荐答案

SecureRandom 仍然是答案.

SecureRandom is still the answer.

我不确定您是从哪里得知 SecureRandom 已被删除或弃用的——它仍然在 2.3.

I'm not sure where you got the idea that SecureRandom has been removed or deprecated -- it's still available in 2.3.

这篇关于如何在 Ruby 中生成随机令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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