Sha256: b4bcad7a74c8a68fa39124f43f031e9d2b0c4c29598a5aa24434eb1125456aff
Contents?: true
Size: 878 Bytes
Versions: 1
Compression:
Stored size: 878 Bytes
Contents
require 'openssl' require 'tempfile' module Heirloom module Cipher class File def initialize(args) @config = args[:config] @aes = OpenSSL::Cipher::AES256.new(:CBC) end def encrypt_file(args) file = args[:file] secret = args[:secret] output = Tempfile.new('archive.tar.gz.enc') iv = @aes.random_iv @aes.encrypt @aes.iv = iv @aes.key = secret # Need to refactor to be less complex # Additionally tests to do fully cover logic ::File.open(output,'w') do |enc| enc << iv ::File.open(file) do |f| loop do r = f.read(4096) break unless r enc << @aes.update(r) end end enc << @aes.final end output.path end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
heirloom-0.5.0rc3 | lib/heirloom/cipher/file.rb |