Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/ios7crypt.rb
Overview
Monkeypatch String to feature #encrypt, #decrypt methods.
Instance Method Summary collapse
Instance Method Details
#decrypt ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/ios7crypt.rb', line 73 def decrypt seed = self[0, 2].to_i hash = self[2, length - 1] pairs = (0 .. (hash.length / 2 - 1)).map do |i| hash[i * 2, 2].to_i(16) end decrypted = (0 .. (pairs.length - 1)).map do |i| IOS7Crypt::XLAT[(seed + i) % IOS7Crypt::XLAT.length] ^ pairs[i] end decrypted.map { |e| e.chr }.join('') end |