Class: Origami::Encryption::RC4
- Inherits:
-
Object
- Object
- Origami::Encryption::RC4
- Defined in:
- lib/origami/encryption.rb
Overview
Class wrapper for the RC4 algorithm.
Class Method Summary collapse
-
.decrypt(key, data) ⇒ Object
Decrypts data using the given key.
-
.encrypt(key, data) ⇒ Object
Encrypts data using the given key.
Instance Method Summary collapse
-
#cipher(data) ⇒ Object
(also: #encrypt, #decrypt)
Encrypt/decrypt data with the RC4 encryption algorithm.
-
#initialize(key) ⇒ RC4
constructor
Creates and initialises a new RC4 generator using given key.
Constructor Details
#initialize(key) ⇒ RC4
Creates and initialises a new RC4 generator using given key
544 545 546 |
# File 'lib/origami/encryption.rb', line 544 def initialize(key) @key = key end |
Class Method Details
Instance Method Details
#cipher(data) ⇒ Object Also known as: encrypt, decrypt
Encrypt/decrypt data with the RC4 encryption algorithm
551 552 553 554 555 556 557 558 559 |
# File 'lib/origami/encryption.rb', line 551 def cipher(data) return '' if data.empty? rc4 = OpenSSL::Cipher::RC4.new.encrypt rc4.key_len = @key.length rc4.key = @key rc4.update(data) + rc4.final end |