Module: Maromi::Helpers::Token

Defined in:
lib/maromi/helpers/token.rb

Overview

There was going to be more to this at one point, but all it does is to generate a random string suitable for use as a token or secret.

Class Method Summary collapse

Class Method Details

.new(size = 32) ⇒ String

Generates a pseudorandom string suitable for use as a token or secret.

Parameters:

  • size (Integer) (defaults to: 32)

    the maximum length of the string

Returns:

  • (String)

    a pseudorandom string



10
11
12
# File 'lib/maromi/helpers/token.rb', line 10

def self.new(size=32)
  Base64.encode64(OpenSSL::Random.random_bytes(size)).gsub(/\W/,'')
end