Module: Crypt::StringXor
- Included in:
- String
- Defined in:
- lib/external/crypt/stringxor.rb
Instance Method Summary collapse
Instance Method Details
#^(aString) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/external/crypt/stringxor.rb', line 7 def ^(aString) a = self.unpack('C'*(self.length)) b = aString.unpack('C'*(aString.length)) if (b.length < a.length) (a.length - b.length).times { b << 0 } end xor = "" 0.upto(a.length-1) { |pos| x = a[pos] ^ b[pos] xor << x.chr() } return(xor) end |