Class: Zip::TraditionalEncrypter

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

Overview

:nodoc:

Instance Method Summary collapse

Methods included from TraditionalEncryption

#gp_flags, #header_bytesize, #initialize

Instance Method Details

#data_descriptor(crc32, compressed_size, uncompressed_size) ⇒ Object



58
59
60
# File 'lib/zip/crypto/traditional_encryption.rb', line 58

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

#encrypt(data) ⇒ Object



54
55
56
# File 'lib/zip/crypto/traditional_encryption.rb', line 54

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

#header(mtime) ⇒ Object



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

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



62
63
64
# File 'lib/zip/crypto/traditional_encryption.rb', line 62

def reset!
  reset_keys!
end