Sha256: 2f079a59c98266cfd3812112274fc67552c65d12d11409044150f501f5774c3b
Contents?: true
Size: 889 Bytes
Versions: 13
Compression:
Stored size: 889 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 archive." @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 archive does not appear to be encrypted.' end @logger.error "Unable to decrypt archive: '#{e.message}'" false end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems