sha1 expects bytes, so we encode str

hashlib.sha1 operates on bytes.