class Veil::Cipher
Constants
- DEFAULT_DECRYPTOR
- DEFAULT_ENCRYPTOR
Public Class Methods
create(opts = {})
click to toggle source
Create a new Cipher
instance
Defaults to using v1 for decryption (noop), v2 for encryption. If invoked as default, v2 will generate key and iv.
@param opts Hash<Symbol> a hash of options to pass to the constructor
@example Veil::Cipher.create
(type: “V1”) @example Veil::Cipher.create
(type: “V2”, key: “blah”, iv: “vi”)
# File lib/veil/cipher.rb, line 21 def create(opts = {}) case opts when {}, nil [ DEFAULT_DECRYPTOR.new({}), DEFAULT_ENCRYPTOR.new({}) ] else cipher = const_get(opts[:type]) [ cipher.new(opts), cipher.new(opts) ] end end