module CloudQuery module Crypto module Random extend self SecureRandom = (defined?(::SecureRandom) && ::SecureRandom) || (defined?(::ActiveSupport::SecureRandom) && ::ActiveSupport::SecureRandom) if SecureRandom def nonce "#{SecureRandom.random_number}.#{Time.now.to_i}"[2..-1] end else def nonce "#{rand.to_s}.#{Time.now.to_i}"[2..-1] end end end module URLSafeSHA1 extend self def sign(*tokens) tokens = tokens.flatten digest = Digest::SHA1.digest(tokens.join) Base64.encode64(digest).chomp.tr('+/', '-_') end end end end