| Class | Origami::Encryption::ARC4 |
| In: |
sources/parser/encryption.rb
|
| Parent: | Object |
Pure Ruby implementation of the aRC4 symmetric algorithm
Decrypts data using the given key
# 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
# File sources/parser/encryption.rb, line 434
434: def ARC4.encrypt(key, data)
435:
436: ARC4.new(key).encrypt(data)
437:
438: end
Encrypt/decrypt data with the aRC4 encryption algorithm
# 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