Module: Origami::Encryption

Defined in:
lib/origami/encryption.rb

Overview

Module to provide support for encrypting and decrypting PDF documents.

Defined Under Namespace

Modules: EncryptedDocument, EncryptedObject, EncryptedStream, EncryptedString, Identity, Standard Classes: AES, CryptFilterDictionary, EncryptionDictionary, RC4

Class Method Summary collapse

Class Method Details

.rand_bytes(n) ⇒ Object

Generates n random bytes from a fast PRNG.



292
293
294
# File 'lib/origami/encryption.rb', line 292

def self.rand_bytes(n)
    Random.new.bytes(n)
end

.strong_rand_bytes(n) ⇒ Object

Generates n random bytes from a crypto PRNG.



299
300
301
302
303
304
305
# File 'lib/origami/encryption.rb', line 299

def self.strong_rand_bytes(n)
    if Origami::OPTIONS[:use_openssl]
        OpenSSL::Random.random_bytes(n)
    else
        SecureRandom.random_bytes(n)
    end
end