Created
March 20, 2014 16:19
-
-
Save slopeofhope81/9667647 to your computer and use it in GitHub Desktop.
creating a secret random key using ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def secure_token | |
token_file = Rails.root.join(".secret") | |
if File.exist?(token_file) | |
File.read(token_file).chomp | |
else | |
token = SecureRandom.hex(64) | |
File.write(token_file, token) | |
token | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment