Skip to content

Commit 294d775

Browse files
Create checksum_tools.py
1 parent 1f14430 commit 294d775

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

glueops/checksum_tools.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import zlib
2+
3+
def string_to_crc32(input_string):
4+
"""Compute CRC32 checksum for a given string and return it in hexadecimal format."""
5+
# Encode the string to bytes
6+
data_bytes = input_string.encode('utf-8')
7+
8+
# Compute CRC32 checksum
9+
checksum = zlib.crc32(data_bytes) & 0xffffffff
10+
11+
# Convert checksum to hexadecimal
12+
hex_checksum = hex(checksum)
13+
14+
return hex_checksum

0 commit comments

Comments
 (0)