Module: Rex::Proto::Kerberos::Crypto::Utils

Included in:
AesBlockCipherBase, Rc4Hmac
Defined in:
lib/rex/proto/kerberos/crypto/utils.rb

Instance Method Summary collapse

Instance Method Details

#xor_bytes(l1, l2) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/rex/proto/kerberos/crypto/utils.rb', line 13

def xor_bytes(l1,l2)
  result = []
  l1.zip(l2).each do |b1,b2|
    if b1 != nil && b2 != nil
      result.append((b1^b2))
    end
  end

  result
end

#xor_strings(s1, s2) ⇒ Object



6
7
8
9
10
11
# File 'lib/rex/proto/kerberos/crypto/utils.rb', line 6

def xor_strings(s1,s2)
  l1 = s1.unpack('C*')
  l2 = s2.unpack('C*')
  result = xor_bytes(l1, l2)
  result.pack('C*')
end