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 443
443:       def ARC4.decrypt(key, data)
444: 
445:         ARC4.new(key).decrypt(data)
446:       
447:       end

Encrypts data using the given key

[Source]

     # File sources/parser/encryption.rb, line 434
434:       def ARC4.encrypt(key, data)
435:      
436:         ARC4.new(key).encrypt(data)
437:         
438:       end

Creates and initialises a new aRC4 generator using given key

[Source]

     # File sources/parser/encryption.rb, line 452
452:       def initialize(key)
453:         
454:         @state = init(key)
455:         
456:       end

Public Instance methods

Encrypt/decrypt data with the aRC4 encryption algorithm

[Source]

     # File sources/parser/encryption.rb, line 461
461:       def cipher(data)
462:       
463:         output = ""
464:         i, j = 0, 0
465:         data.each_byte do |byte|
466:           i = i.succ & 0xFF
467:           j = (j + @state[i]) & 0xFF
468:           
469:           @state[i], @state[j] = @state[j], @state[i]
470:           
471:           output << (@state[@state[i] + @state[j] & 0xFF] ^ byte).chr
472:         end
473:       
474:         output
475:       end
decrypt(data)

Alias for cipher

encrypt(data)

Alias for cipher

[Validate]