Class: Omnizip::Formats::Rar::Rar5::Models::EncryptionOptions

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/omnizip/formats/rar/rar5/models/encryption_options.rb

Overview

Encryption options for RAR5 archives

This model configures password-based encryption using AES-256-CBC with PBKDF2-HMAC-SHA256 key derivation.

Examples:

Enable encryption with default settings

options = EncryptionOptions.new(
  enabled: true,
  password: "SecurePassword123"
)

Custom KDF iterations

options = EncryptionOptions.new(
  enabled: true,
  password: "SecurePassword123",
  kdf_iterations: 524_288  # 2^19, higher security
)

Instance Method Summary collapse

Instance Method Details

#enabled?Boolean

Check if encryption is enabled

Returns:

  • (Boolean)

    true if enabled



59
60
61
# File 'lib/omnizip/formats/rar/rar5/models/encryption_options.rb', line 59

def enabled?
  enabled == true
end

#has_password?Boolean

Check if password is set

Returns:

  • (Boolean)

    true if password provided



66
67
68
# File 'lib/omnizip/formats/rar/rar5/models/encryption_options.rb', line 66

def has_password?
  !password.nil? && !password.empty?
end

#validate!Object

Validate options

Raises:

  • (ArgumentError)

    If validation fails



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/omnizip/formats/rar/rar5/models/encryption_options.rb', line 44

def validate!
  if enabled? && (password.nil? || password.empty?)
    raise ArgumentError,
          "Password required when encryption is enabled"
  end

  if kdf_iterations < 65_536 || kdf_iterations > 1_048_576
    raise ArgumentError,
          "KDF iterations must be between 65,536 and 1,048,576"
  end
end