[Tutor] XOR, bytes and strings
dyoo at hkn.eecs.berkeley.edu
Wed Jan 4 21:55:12 CET 2006
> i'm a totally newbie to python, but i can't resist to try to communicyte
> with an ICQ-server via my own tool.
> now i have the problem that i should encrypt a string (the password) by
> XOR with this bytes: f3, 26, 81, c4, 39, 86, db, 92, 71, a3, b9, e6, 53,
> 7a, 95, 7c.
I think you're looking for the exclusive or (XOR) bitwise operator '^'.
>>> bits = [0, 1]
>>> for x in bits:
... for y in bits:
... print x, y, x ^ y
0 0 0
0 1 1
1 0 1
1 1 0
Is this where you're getting stuck, or is it somewhere else?
Good luck to you.
More information about the Tutor