Module: AttrEncrypter::Generator

Defined in:
lib/attr_encrypter/generator.rb

Class Method Summary collapse

Class Method Details

.generate_key(version = 1) ⇒ Object


5
6
7
8
9
10
11
# File 'lib/attr_encrypter/generator.rb', line 5

def self.generate_key(version = 1)
  byte_size    = RbNaCl::SecretBox.key_bytes
  secret_bytes = RbNaCl::Random.random_bytes(byte_size)
  secret_hex   = secret_bytes.unpack("H*")[0]

  "#{version}.#{secret_hex}"
end