MCPcopy
hub / github.com/borgbackup/borg / hex_to_bin

Function hex_to_bin

src/borg/helpers/parseformat.py:50–58  ·  view source on GitHub ↗
(hex, length=None)

Source from the content-addressed store, hash-verified

48
49
50def hex_to_bin(hex, length=None):
51 try:
52 binary = binascii.unhexlify(hex)
53 binary_len = len(binary)
54 if length is not None and binary_len != length:
55 raise ValueError(f"Expected {length} bytes ({2 * length} hex digits), got {binary_len} bytes.")
56 except binascii.Error as e:
57 raise ValueError(str(e)) from None
58 return binary
59
60
61def safe_decode(s, coding="utf-8", errors="surrogateescape"):

Callers 15

loadMethod · 0.85
openMethod · 0.85
checkMethod · 0.85
listMethod · 0.85
openMethod · 0.85
idsMethod · 0.85
import_paperkeyMethod · 0.85
do_debug_get_objMethod · 0.85
do_debug_parse_objMethod · 0.85
do_debug_format_objMethod · 0.85

Calls

no outgoing calls

Tested by 5

test_xxh64Function · 0.68
test_key_export_paperkeyFunction · 0.68
test_key_import_paperkeyFunction · 0.68