Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate credentials with SecureRandom.alphanumeric instead of SecureRandom.hex #43359

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion railties/lib/rails/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ def generate_development_secret
key_file = Rails.root.join("tmp/development_secret.txt")

if !File.exist?(key_file)
random_key = SecureRandom.hex(64)
random_key = SecureRandom.alphanumeric(128)
FileUtils.mkdir_p(key_file.dirname)
File.binwrite(key_file, random_key)
end
Expand Down
2 changes: 1 addition & 1 deletion railties/lib/rails/tasks/misc.rake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
desc "Generate a cryptographically secure secret key (this is typically used to generate a secret for cookie sessions)."
task :secret do
require "securerandom"
puts SecureRandom.hex(64)
puts SecureRandom.alphanumeric(128)
end

desc "List versions of all Rails frameworks and the environment"
Expand Down