Skip to content

Commit 7dccfc2

Browse files
committed
feat: common
1 parent 896fb5f commit 7dccfc2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

apps/common/utils/common.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,10 @@ def bulk_create_in_batches(model, data, batch_size=1000):
280280
model.objects.bulk_create(batch)
281281

282282

283-
def get_sha256_hash(_v: str):
283+
def get_sha256_hash(_v: str | bytes):
284284
sha256 = hashlib.sha256()
285-
sha256.update(_v.encode())
285+
if isinstance(_v, str):
286+
sha256.update(_v.encode())
287+
else:
288+
sha256.update(_v)
286289
return sha256.hexdigest()

0 commit comments

Comments
 (0)