Class: RUtilAnts::Archive::StringReader

Inherits:
Object
  • Object
show all
Defined in:
lib/rUtilAnts/Archive.rb

Overview

Class used to give the decoders a streaming interface

Instance Method Summary collapse

Constructor Details

#initialize(iPassword, iSalt, iFile) ⇒ StringReader

Constructor

Parameters
  • iPassword (String): Password encrypting data

  • iSalt (String): Salt encoding data

  • iFile (IO): The IO that will send encrypted data



74
75
76
# File 'lib/rUtilAnts/Archive.rb', line 74

def initialize(iPassword, iSalt, iFile)
  @Password, @Salt, @File = iPassword, iSalt, iFile
end

Instance Method Details

#getObject

Get the next string encrypted

Return
  • String: The next string encrypted (or nil if none)



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/rUtilAnts/Archive.rb', line 82

def get
  rObject = nil

  # Read
  lStrChunkSize = @File.read(4)
  if (lStrChunkSize != nil)
    lChunkSize = lStrChunkSize.unpack('l')[0]
    lData = @File.read(lChunkSize)
    # Decrypt
    lDecryptedData = EzCrypto::Key.decrypt_with_password(@Password, @Salt, lData)
    # Uncompress
    rObject = Zlib::Inflate.new.inflate(lDecryptedData)
  end

  return rObject
end