Pure Ruby implementation of the aRC4 symmetric algorithm
Decrypts data using the given key
# File lib/origami/encryption.rb, line 563 def ARC4.decrypt(key, data) ARC4.new(key).decrypt(data) end
Encrypt/decrypt data with the aRC4 encryption algorithm
# File lib/origami/encryption.rb, line 581 def cipher(data) return "" if data.empty? if Origami::OPTIONS[:use_openssl] rc4 = OpenSSL::Cipher::RC4.new.encrypt rc4.key_len = @key.length rc4.key = @key output = rc4.update(data) << rc4.final else output = "" i, j = 0, 0 data.each_byte do |byte| i = i.succ & 0xFF j = (j + @state[i]) & 0xFF @state[i], @state[j] = @state[j], @state[i] output << (@state[@state[i] + @state[j] & 0xFF] ^ byte).chr end end output end
Generated with the Darkfish Rdoc Generator 2.