MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / to_bytes

Function to_bytes

pager_lib/pyasn1/compat/integer.py:7–13  ·  view source on GitHub ↗
(value, signed=False, length=0)

Source from the content-addressed store, hash-verified

5# License: https://pyasn1.readthedocs.io/en/latest/license.html
6#
7def to_bytes(value, signed=False, length=0):
8 length = max(value.bit_length(), length)
9
10 if signed and length % 8 == 0:
11 length += 1
12
13 return value.to_bytes(length // 8 + (length % 8 and 1 or 0), 'big', signed=signed)

Callers 1

encodeValueMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected