哪个方法用于生成“Application.config.secret_token ='...'”?

时间:2015-05-22 01:00:53

标签: ruby-on-rails

在Rails 3.2中,每个应用的config/secret_token.rb都有一个secret_token

ProjectName::Application.config.secret_token = 'c9d1a7ea24444ddf06e4b52a7a08174fc9bc7483727b8ec674d6360f2fb93db007114971feeb1e0f69d6dda595dafb30956b057962aad44a137295128a6d23c0' 

我很好奇哪个方法Rails用于生成128位代码:c9d1a7ea24444ddf06e4b52a7a08174fc9bc7483727b8ec674d6360f2fb93db007114971feeb1e0f69d6dda595dafb30956b057962aad44a137295128a6d23c0。我试过SecureRandom,但似乎没有这样的方法?

1 个答案:

答案 0 :(得分:1)

你想要long excessTicks = timestamp.Ticks % 10000; timestamp= new DateTime( ticks: timestamp.Ticks - excessTicks, kind: timestamp.Kind );

http://www.jamesbadger.ca/2012/12/18/generate-new-secret-token/