Skip to content

JBushagour/hackxor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

hackxor

hackxor (pronounced "haxor" [1]) is an evil cool library that turns the ^ operator into exponentiation on ints and floats. You know, akin to other great programming languages like... VBA?

>>> x = 2
>>> print(x ^ 2)
0
>>> import hackxor
>>> print(x ^ 2)
4

Once you import hackxor, things will randomly break. Pretty sick.

>>> import hackxor
>>> import hmac
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.12/hmac.py", line 19, in <module>
    trans_5C = bytes((x ^ 0x5C) for x in range(256))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: bytes must be in range(0, 256)

Note: Python's ast optimizier performs simple constant folding. Because of this, you might see some confusing cool behavior.

>>> from pathlib import Path
>>> print(Path("surprise.py").read_text())
print(2 ^ 2)
x = 2
print(x ^ 2)
>>> import hackxor
>>> import surprise
0
4

[1] Haxor, and derivations thereof, is leet for "hacker".

About

A Python library that does evil things to __xor__.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages