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.
48 49 50 51 52 |
# File 'lib/hexapdf/encryption/fast_arc4.rb', line 48 def initialize(key) @cipher = OpenSSL::Cipher::RC4.new @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.
58 59 60 |
# File 'lib/hexapdf/encryption/fast_arc4.rb', line 58 def process(data) @cipher.update(data) end |