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, ARC4, CryptFilterDictionary, EncryptionDictionary
Class Method Summary collapse
-
.rand_bytes(n) ⇒ Object
Generates n random bytes from a fast PRNG.
-
.strong_rand_bytes(n) ⇒ Object
Generates n random bytes from a crypto PRNG.
Class Method Details
.rand_bytes(n) ⇒ Object
Generates n random bytes from a fast PRNG.
303 304 305 |
# File 'lib/origami/encryption.rb', line 303 def self.rand_bytes(n) ::Array.new(n) { rand(256) }.pack("C*") end |
.strong_rand_bytes(n) ⇒ Object
Generates n random bytes from a crypto PRNG.
310 311 312 313 314 315 316 317 318 |
# File 'lib/origami/encryption.rb', line 310 def self.strong_rand_bytes(n) if Origami::OPTIONS[:use_openssl] OpenSSL::Random.random_bytes(n) elsif RUBY_VERSION >= '1.9' Random.new.bytes(n) else self.rand_bytes(n) end end |