public Method

SecretKeyGenerator.generate_secret_with_prng

Generate a random secret key with Ruby’s pseudo random number generator, as well as some environment information.

This is the least cryptographically secure way to generate a secret key, and should be avoided whenever possible.

Source Code

# File rails_generator/secret_key_generator.rb, line 94
def generate_secret_with_prng
  require 'digest/sha2'
  sha = Digest::SHA2.new(512)
  now = Time.now
  sha << now.to_s
  sha << String(now.usec)
  sha << String(rand(0))
  sha << String($$)
  sha << @identifier
  return sha.hexdigest
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.