Sha256: 8bfce523b9f63d90a89d2f35088145641a4d20bb26d53853e3fca9e39abab96e
Contents?: true
Size: 892 Bytes
Versions: 5
Compression:
Stored size: 892 Bytes
Contents
require 'openssl' module Heirloom module Cipher class Data def initialize(args) @config = args[:config] @logger = @config.logger end def decrypt_data(args) data = args[:data] secret = args[:secret] return data unless args[:secret] @logger.info "Secret provided. Decrypting Heirloom." @aes = OpenSSL::Cipher::AES256.new(:CBC) @aes.decrypt @aes.key = Digest::SHA256.hexdigest secret @aes.iv = data.slice!(0,16) begin @aes.update(data) + @aes.final rescue OpenSSL::Cipher::CipherError => e if e.message == 'wrong final block length' @logger.error 'This Heirloom does not appear to be encrypted.' end @logger.error "Unable to decrypt Heirloom: '#{e.message}'" false end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems