Class: Ccrypto::Ruby::SecretKeyEngine

Inherits:
Object
  • Object
show all
Defined in:
lib/ccrypto/ruby/engines/secret_key_engine.rb

Class Method Summary collapse

Class Method Details

.generate(*args, &block) ⇒ Object

Raises:

  • (SecretKeyEngineException)


7
8
9
10
11
12
13
14
15
# File 'lib/ccrypto/ruby/engines/secret_key_engine.rb', line 7

def self.generate(*args, &block)
  config = args.first

  raise SecretKeyEngineException, "KeyConfig is expected" if not config.is_a?(Ccrypto::KeyConfig) 

  key = SecureRandom.random_bytes(config.keysize/8)

  Ccrypto::SecretKey.new(config.algo, key)
end