Class: Zip::ExtraField::AES
- Defined in:
- lib/zip/extra_field/aes.rb
Overview
Info-ZIP Extra for AES encryption
Constant Summary collapse
- HEADER_ID =
[0x9901].pack('v')
Instance Attribute Summary collapse
-
#compression_method ⇒ Object
readonly
:nodoc:.
-
#encryption_strength ⇒ Object
readonly
:nodoc:.
-
#vendor_id ⇒ Object
readonly
:nodoc:.
-
#vendor_version ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(binstr = nil) ⇒ AES
constructor
A new instance of AES.
- #merge(binstr) ⇒ Object
- #pack_for_c_dir ⇒ Object
- #pack_for_local ⇒ Object
Methods inherited from Generic
#initial_parse, name, register_map, #to_c_dir_bin, #to_local_bin
Constructor Details
#initialize(binstr = nil) ⇒ AES
Returns a new instance of AES.
11 12 13 14 15 16 17 |
# File 'lib/zip/extra_field/aes.rb', line 11 def initialize(binstr = nil) @vendor_version = nil @vendor_id = nil @encryption_strength = nil @compression_method = nil binstr && merge(binstr) end |
Instance Attribute Details
#compression_method ⇒ Object (readonly)
:nodoc:
6 7 8 |
# File 'lib/zip/extra_field/aes.rb', line 6 def compression_method @compression_method end |
#encryption_strength ⇒ Object (readonly)
:nodoc:
6 7 8 |
# File 'lib/zip/extra_field/aes.rb', line 6 def encryption_strength @encryption_strength end |
#vendor_id ⇒ Object (readonly)
:nodoc:
6 7 8 |
# File 'lib/zip/extra_field/aes.rb', line 6 def vendor_id @vendor_id end |
#vendor_version ⇒ Object (readonly)
:nodoc:
6 7 8 |
# File 'lib/zip/extra_field/aes.rb', line 6 def vendor_version @vendor_version end |
Instance Method Details
#==(other) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/zip/extra_field/aes.rb', line 19 def ==(other) @vendor_version == other.vendor_version && @vendor_id == other.vendor_id && @encryption_strength == other.encryption_strength && @compression_method == other.compression_method end |
#merge(binstr) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/zip/extra_field/aes.rb', line 26 def merge(binstr) return if binstr.empty? size, content = initial_parse(binstr) (size && content) || return @vendor_version, @vendor_id, @encryption_strength, @compression_method = content.unpack('va2Cv') end |
#pack_for_c_dir ⇒ Object
41 42 43 |
# File 'lib/zip/extra_field/aes.rb', line 41 def pack_for_c_dir pack_for_local end |
#pack_for_local ⇒ Object
36 37 38 39 |
# File 'lib/zip/extra_field/aes.rb', line 36 def pack_for_local [@vendor_version, @vendor_id, @encryption_strength, @compression_method].pack('va2Cv') end |