Class: Zip::TraditionalEncrypter

Inherits:
Encrypter show all
Includes:
TraditionalEncryption
Defined in:
lib/zip/crypto/traditional_encryption.rb

Instance Method Summary collapse

Methods included from TraditionalEncryption

#gp_flags, #header_bytesize, #initialize

Instance Method Details

#data_descriptor(crc32, compressed_size, uncomprssed_size) ⇒ Object



56
57
58
# File 'lib/zip/crypto/traditional_encryption.rb', line 56

def data_descriptor(crc32, compressed_size, uncomprssed_size)
  [0x08074b50, crc32, compressed_size, uncomprssed_size].pack('VVVV')
end

#encrypt(data) ⇒ Object



52
53
54
# File 'lib/zip/crypto/traditional_encryption.rb', line 52

def encrypt(data)
  data.unpack('C*').map { |x| encode x }.pack('C*')
end

#header(mtime) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/zip/crypto/traditional_encryption.rb', line 42

def header(mtime)
  [].tap do |header|
    (header_bytesize - 2).times do
      header << Random.rand(0..255)
    end
    header << (mtime.to_binary_dos_time & 0xff)
    header << (mtime.to_binary_dos_time >> 8)
  end.map { |x| encode x }.pack('C*')
end

#reset!Object



60
61
62
# File 'lib/zip/crypto/traditional_encryption.rb', line 60

def reset!
  reset_keys!
end