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



79
80
81
# File 'lib/rUtilAnts/Archive.rb', line 79

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)



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/rUtilAnts/Archive.rb', line 87

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