Method: PDF::Reader::StandardKeyBuilder#key

Defined in:
lib/pdf/reader/standard_key_builder.rb

#key(pass = "") ⇒ Object

Takes a string containing a user provided password.

If the password matches the file, then a string containing a key suitable for decrypting the file will be returned. If the password doesn’t match the file, and exception will be raised.

: (?String) -> String



53
54
55
56
57
58
59
# File 'lib/pdf/reader/standard_key_builder.rb', line 53

def key(pass = "")
  encrypt_key   = auth_owner_pass(pass)
  encrypt_key ||= auth_user_pass(pass)

  raise PDF::Reader::EncryptedPDFError, "Invalid password (#{pass})" if encrypt_key.nil?
  encrypt_key
end