Didactic XOR
My solution in ruby:
Code: Select all
input = ["9f", "c7"]
input.map! {
|x| x.to_i(16)
}
output = input.first ^ input.last
puts output.chr
Use "calc.exe" in Scientific mode. Select Hex as numeration base then XOR 9f with c7.
=> 58 which converted to ASCII = 'X'
Python:
=> X
=> 58 which converted to ASCII = 'X'
Python:
Code: Select all
a = 0x9f
b = 0xc7
print chr(a^b)
Python is faster:wynk wrote:My solution in ruby:
Code: Select all
input = ["9f", "c7"] input.map! { |x| x.to_i(16) } output = input.first ^ input.last puts output.chr
Code: Select all
"%c"%(0x9f ^ 0xc7)
I don't know if i missed something here, But I used the same method 'calc.exe'lortedy wrote:Use "calc.exe" in Scientific mode. Select Hex as numeration base then XOR 9f with c7.
=> 58 which converted to ASCII = 'X'
Python:=> XCode: Select all
a = 0x9f b = 0xc7 print chr(a^b)
I got 58 but in ascii 58 = :
so i tried : and it was a error.
I converted it to .decimal and it was 88(x)
Which worked.
So isn't 58 on ascii table this symbol : ??
The first principle is that you must not fool yourself - and you are the easiest person to fool.