Module: SaltGenerator

Defined in:
lib/arkana/salt_generator.rb

Overview

Responsible for generating the salt.

Constant Summary collapse

SALT_LENGTH =
64

Class Method Summary collapse

Class Method Details

.generateSalt

Generates and returns a new Salt object.

Returns:

  • (Salt)

    the salt that was just generated.



13
14
15
16
17
# File 'lib/arkana/salt_generator.rb', line 13

def self.generate
  chars = SecureRandom.random_bytes(SALT_LENGTH).chars # Convert array of random bytes to array of characters
  codepoints = chars.map(&:ord) # Convert each character to its codepoint representation
  Salt.new(raw: codepoints)
end