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

Method fromHexString

pager_lib/pyasn1/type/univ.py:564–586  ·  view source on GitHub ↗

Create a |ASN.1| object initialized from the hex string. Parameters ---------- value: :class:`str` Text string like 'DEADBEEF'

(cls, value, internalFormat=False, prepend=None)

Source from the content-addressed store, hash-verified

562
563 @classmethod
564 def fromHexString(cls, value, internalFormat=False, prepend=None):
565 """Create a |ASN.1| object initialized from the hex string.
566
567 Parameters
568 ----------
569 value: :class:`str`
570 Text string like 'DEADBEEF'
571 """
572 try:
573 value = SizedInteger(value, 16).setBitLength(len(value) * 4)
574
575 except ValueError as exc:
576 raise error.PyAsn1Error('%s.fromHexString() error: %s' % (cls.__name__, exc))
577
578 if prepend is not None:
579 value = SizedInteger(
580 (SizedInteger(prepend) << len(value)) | value
581 ).setBitLength(len(prepend) + len(value))
582
583 if not internalFormat:
584 value = cls(value)
585
586 return value
587
588 @classmethod
589 def fromBinaryString(cls, value, internalFormat=False, prepend=None):

Callers 2

__init__Method · 0.95
prettyInMethod · 0.95

Calls 2

SizedIntegerClass · 0.85
setBitLengthMethod · 0.80

Tested by

no test coverage detected