Module: HexaPDF::Encryption::ARC4::ClassMethods
- Defined in:
- lib/hexapdf/encryption/arc4.rb
Overview
Convenience methods for decryption and encryption that operate according to the PDF specification.
These methods will be available on the class object that prepends the ARC4 module.
Instance Method Summary collapse
-
#encrypt(key, data) ⇒ Object
(also: #decrypt)
Encrypts the given
data
with thekey
. -
#encryption_fiber(key, source) ⇒ Object
(also: #decryption_fiber)
Returns a Fiber object that encrypts the data from the given source fiber with the
key
.
Instance Method Details
#encrypt(key, data) ⇒ Object Also known as: decrypt
Encrypts the given data
with the key
.
See: PDF2.0 s7.6.3
69 70 71 |
# File 'lib/hexapdf/encryption/arc4.rb', line 69 def encrypt(key, data) new(key).process(data) end |
#encryption_fiber(key, source) ⇒ Object Also known as: decryption_fiber
Returns a Fiber object that encrypts the data from the given source fiber with the key
.
76 77 78 79 80 81 82 83 |
# File 'lib/hexapdf/encryption/arc4.rb', line 76 def encryption_fiber(key, source) Fiber.new do algorithm = new(key) while source.alive? && (data = source.resume) Fiber.yield(algorithm.process(data)) unless data.empty? end end end |