From af75583b23db2bc6848fa1131cf9f66f073c8549 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 4 Mar 2012 11:05:02 +0000 Subject: Adds Redmine::Utils.random_hex for generating a random hex string. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9071 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redmine/utils.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib') diff --git a/lib/redmine/utils.rb b/lib/redmine/utils.rb index 593406eb1..96580168f 100644 --- a/lib/redmine/utils.rb +++ b/lib/redmine/utils.rb @@ -33,6 +33,13 @@ module Redmine ActionController::AbstractRequest.relative_url_root=arg end end + + # Generates a n bytes random hex string + # Example: + # random_hex(4) # => "89b8c729" + def random_hex(n) + ActiveSupport::SecureRandom.hex(n) + end end end end -- cgit v1.2.3