Refactor to work more like hashlib