Skip to content

Instantly share code, notes, and snippets.

@vxr
vxr / multihash.py
Created October 24, 2014 02:03
MultiHash Python Class, hashes input with all available algorithms in hashlib
class MultiHash(object):
def __init__(self, initial_value, **kwargs):
self._hashes = []
if hasattr(initial_value, 'read'):
file_handle = initial_value
args = tuple()
else:
file_handle = None
args = (initial_value,)
for algorithm in hashlib.algorithms:
### Keybase proof
I hereby claim:
* I am vxr on github.
* I am vxr (https://keybase.io/vxr) on keybase.
* I have a public key whose fingerprint is 3FBF 3F81 F35A 75BF 5517 5559 DA56 3B3E 7B3E 6BE9
To claim this, I am signing this object:
@vxr
vxr / gist:0823f9a0e0c1b11dff53
Last active August 29, 2015 14:04
Quick rotate example (python)
def rorb(value):
return ((value >> 1) | ((value & 1) << 7)) & 0xFF
def rorb_count(value, count):
for x in range(count):
value = rorb(value)
return value