module GoodData::Helpers::CryptoHelper
Public Class Methods
Source
# File lib/gooddata/helpers/crypto_helper.rb, line 13 def generate_password sprinkle(SecureRandom.base64(32)) end
Private Class Methods
Source
# File lib/gooddata/helpers/crypto_helper.rb, line 33 def digit (0..9).to_a.sample.to_s end
Source
# File lib/gooddata/helpers/crypto_helper.rb, line 37 def lower ('a'..'z').to_a.sample end
Source
# File lib/gooddata/helpers/crypto_helper.rb, line 23 def sprinkle(password) password_dup = password.dup positions = 0..password.size password_dup.insert(rand(positions), digit) password_dup.insert(rand(positions), lower) password_dup.insert(rand(positions), upper) password_dup.insert(rand(positions), symbol) password_dup end
Pseudo-randomly “sprinkles” the given string with 4 character groups (digit, lower case, upper case, symbols). @param [String] password
Source
# File lib/gooddata/helpers/crypto_helper.rb, line 45 def symbol '!@#$%&/()+?*'.chars.sample end
Source
# File lib/gooddata/helpers/crypto_helper.rb, line 41 def upper ('A'..'Z').to_a.sample end