Class Origami::Encryption::ARC4
In: sources/parser/encryption.rb
Parent: Object

Pure Ruby implementation of the aRC4 symmetric algorithm

Methods

cipher   decrypt   decrypt   encrypt   encrypt   new  

Public Class methods

Decrypts data using the given key

[Source]

     # File sources/parser/encryption.rb, line 376
376:       def ARC4.decrypt(key, data)
377: 
378:         ARC4.new(key).decrypt(data)
379:       
380:       end

Encrypts data using the given key

[Source]

     # File sources/parser/encryption.rb, line 367
367:       def ARC4.encrypt(key, data)
368:      
369:         ARC4.new(key).encrypt(data)
370:         
371:       end

Creates and initialises a new aRC4 generator using given key

[Source]

     # File sources/parser/encryption.rb, line 385
385:       def initialize(key)
386:         
387:         @state = init(key)
388:         
389:       end

Public Instance methods

Encrypt/decrypt data with the aRC4 encryption algorithm

[Source]

     # File sources/parser/encryption.rb, line 394
394:       def cipher(data)
395:       
396:         output = ""
397:         i, j = 0, 0
398:         data.each_byte do |byte|
399:           i = i.succ & 0xFF
400:           j = (j + @state[i]) & 0xFF
401:           
402:           @state[i], @state[j] = @state[j], @state[i]
403:           
404:           output << (@state[@state[i] + @state[j] & 0xFF] ^ byte).chr
405:         end
406:       
407:         output
408:       end
decrypt(data)

Alias for cipher

encrypt(data)

Alias for cipher

[Validate]