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 376 376: def ARC4.decrypt(key, data) 377: 378: ARC4.new(key).decrypt(data) 379: 380: end
Encrypts data using the given key
# File sources/parser/encryption.rb, line 367 367: def ARC4.encrypt(key, data) 368: 369: ARC4.new(key).encrypt(data) 370: 371: end
Encrypt/decrypt data with the aRC4 encryption algorithm
# 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