module Origami::Encryption::EncryptedObject
Module for encrypted PDF
objects.
Attributes
decrypted[RW]
Public Instance Methods
post_build()
click to toggle source
Calls superclass method
# File lib/origami/encryption.rb, line 358 def post_build encrypt! super end
Private Instance Methods
compute_object_key(cipher)
click to toggle source
# File lib/origami/encryption.rb, line 366 def compute_object_key(cipher) doc = self.document raise EncryptionError, "Document is not encrypted" unless doc.is_a?(EncryptedDocument) encryption_key = doc.encryption_key if doc.encryption_handler.V < 5 parent = self.indirect_parent no, gen = parent.no, parent.generation k = encryption_key + [no].pack("I")[0..2] + [gen].pack("I")[0..1] key_len = [k.length, 16].min k << "sAlT" if cipher == Encryption::AES Digest::MD5.digest(k)[0, key_len] else encryption_key end end