class EncryptedYaml::Decrypt

Handles decryption @note uses AES256

Public Class Methods

new(key, iv) click to toggle source

@param key [String] encryption key @param iv [String] encyption iv

# File lib/encrypted_yaml/decrypt.rb, line 9
def initialize(key, iv)
  @key = key
  @iv = iv
end

Public Instance Methods

decrypt(data) click to toggle source

@param data [String] encrypted data @return [String] decrypted data

# File lib/encrypted_yaml/decrypt.rb, line 16
def decrypt(data)
  cipher = get_cipher
  cipher.update(data) + cipher.final
end

Private Instance Methods

get_cipher() click to toggle source

@return [OpenSSL::Cipher] initialized cipher ready for decryption

# File lib/encrypted_yaml/decrypt.rb, line 24
def get_cipher
  cipher = OpenSSL::Cipher::AES256.new :CBC
  cipher.decrypt
  cipher.key = @key
  cipher.iv = @iv
  
  cipher
end