mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
Refactor bytes_hash function to handle string input
This commit is contained in:
parent
d6d3950f01
commit
6f16da357a
1 changed files with 4 additions and 2 deletions
|
|
@ -64,8 +64,10 @@ def file_hash(file: Union[str, Path]) -> str:
|
|||
return _sha512.hexdigest()
|
||||
|
||||
|
||||
def bytes_hash(bio: Union[bytes, BytesIO]) -> str:
|
||||
if isinstance(bio, bytes):
|
||||
def bytes_hash(bio: Union[str, bytes, BytesIO]) -> str:
|
||||
if isinstance(bio, str):
|
||||
bio = BytesIO(bio.encode("utf-8"))
|
||||
elif isinstance(bio, bytes):
|
||||
bio = BytesIO(bio)
|
||||
|
||||
assert isinstance(bio, BytesIO)
|
||||
|
|
|
|||
Loading…
Reference in a new issue