class HexaPDF::Encryption::FastARC4

Implementation of the general encryption algorithm ARC4 using OpenSSL as backend.

See: PDF1.7 s7.6.2

Public Class Methods

new(key) click to toggle source

Creates a new FastARC4 object using the given encryption key.

# File lib/hexapdf/encryption/fast_arc4.rb, line 50
def initialize(key)
  @cipher = OpenSSL::Cipher.new('rc4')
  @cipher.key_len = key.length
  @cipher.key = key
end

Public Instance Methods

decrypt(data)
Alias for: process
encrypt(data)
Alias for: process
process(data) click to toggle source

Processes the given data.

Since this is a symmetric algorithm, the same method can be used for encryption and decryption.

# File lib/hexapdf/encryption/fast_arc4.rb, line 60
def process(data)
  @cipher.update(data)
end
Also aliased as: decrypt, encrypt