rewrite for hashlib