class HexaPDF::Encryption::StandardSecurityHandler::EncryptionOptions

up encryption.
Defines all possible options that can be passed to a StandardSecurityHandler when setting

def initialize(data = {})

:nodoc:
def initialize(data = {})
  fallback_pwd = data.delete(:password) { '' }
  @user_password = data.delete(:user_password) { fallback_pwd }
  @owner_password = data.delete(:owner_password) { fallback_pwd }
  @owner_password = @user_password if @owner_password.to_s.empty?
  @permissions = process_permissions(data.delete(:permissions) { Permissions::ALL })
  @algorithm = data.delete(:algorithm) { :arc4 }
  @encrypt_metadata = data.delete(:encrypt_metadata) { true }
  unless data.empty?
    raise ArgumentError, "Invalid encryption options: #{data.keys.join(', ')}"
  end
end

def process_permissions(perms)

See: PDF2.0 s7.6.4.2, ADB1.7 3.5.2 (table 3.20 and the paragraphs before)

Maps the permissions to an integer for use by the standard security handler.
def process_permissions(perms)
  if perms.kind_of?(Array)
    perms = perms.inject(0) do |result, perm|
      result | Permissions::SYMBOL_TO_PERMISSION.fetch(perm, 0)
    end
  end
  ((Permissions::RESERVED | perms) & 0xFFFFFFFC) - 2**32
end