lib/megar/adapters/file_downloader.rb
# Returns the complete decrypted content.
# If anything goes wrong here, it's going to bubble up an unhandled error.
#
Returns the complete decrypted content.
If anything goes wrong here, it's going to bubble up an unhandled error.
Returns the complete decrypted content . If anything goes wrong here it ' s going to bubble up an unhandled error .
def content
    return unless live_session?
    decoded_content = ''
    calculated_mac = [0, 0, 0, 0]
    decryptor = get_file_cipher(decomposed_key,iv)
    get_chunks(download_size).each do |chunk_start, chunk_size|
      chunk = stream.readpartial(chunk_size)
      decoded_chunk = decryptor.update(chunk)
      decoded_content << decoded_chunk
      calculated_mac = accumulate_mac(decoded_chunk,calculated_mac,decomposed_key,chunk_mac_iv)
    end
    raise Megar::MacVerificationError.new unless ([calculated_mac[0] ^ calculated_mac[1], calculated_mac[2] ^ calculated_mac[3]] == mac)
    decoded_content
  end
def content return unless live_session? decoded_content = '' calculated_mac = [ 0 , 0 , 0 , 0 ] decryptor = get_file_cipher ( decomposed_key , iv ) get_chunks ( download_size ) . each do | chunk_start , chunk_size | chunk = stream . readpartial ( chunk_size ) decoded_chunk = decryptor . update ( chunk ) decoded_content << decoded_chunk calculated_mac = accumulate_mac ( decoded_chunk , calculated_mac , decomposed_key , chunk_mac_iv ) end raise Megar :: MacVerificationError . new unless ( [ calculated_mac [ 0 ] ^ calculated_mac [ 1 ] , calculated_mac [ 2 ] ^ calculated_mac [ 3 ] ] == mac ) decoded_content end
Returns the complete decrypted content.
Returns the complete decrypted content .