Class: HexaPDF::Encryption::FastARC4
- Inherits:
-
Object
- Object
- HexaPDF::Encryption::FastARC4
- Includes:
- ARC4
- Defined in:
- lib/hexapdf/encryption/fast_arc4.rb
Overview
Implementation of the general encryption algorithm ARC4 using OpenSSL as backend.
See: PDF1.7 s7.6.2
Instance Method Summary collapse
-
#initialize(key) ⇒ FastARC4
constructor
Creates a new FastARC4 object using the given encryption key.
-
#process(data) ⇒ Object
(also: #decrypt, #encrypt)
Processes the given data.
Methods included from ARC4
Constructor Details
#initialize(key) ⇒ FastARC4
Creates a new FastARC4 object using the given encryption key.
51 52 53 54 55 |
# File 'lib/hexapdf/encryption/fast_arc4.rb', line 51 def initialize(key) @cipher = OpenSSL::Cipher.new('rc4') @cipher.key_len = key.length @cipher.key = key end |
Instance Method Details
#process(data) ⇒ Object Also known as: decrypt, encrypt
Processes the given data.
Since this is a symmetric algorithm, the same method can be used for encryption and decryption.
61 62 63 |
# File 'lib/hexapdf/encryption/fast_arc4.rb', line 61 def process(data) @cipher.update(data) end |