Home | Trees | Indices | Help |
|
---|
|
object --+ | DerObject --+ | DerBitString
Class to model a DER BIT STRING.
An example of encoding is:
>>> from Crypto.Util.asn1 import DerBitString >>> from binascii import hexlify, unhexlify >>> bs_der = DerBitString(b'\xaa') >>> bs_der.value += b'\xbb' >>> print hexlify(bs_der.encode())
which will show 040300aabb, the DER encoding for the bit string b'\xAA\xBB'.
For decoding:
>>> s = unhexlify(b'040300aabb') >>> try: >>> bs_der = DerBitString() >>> bs_der.decode(s) >>> print hexlify(bs_der.value) >>> except (ValueError, EOFError): >>> print "Not a valid DER OCTET STRING"
the output will be aabb.
Instance Methods | |||
|
|||
|
|||
|
|||
Inherited from |
Instance Variables | |
value The bitstring value (packed) |
Properties | |
Inherited from |
Method Details |
|
|
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sun Apr 3 03:23:26 2016 | http://epydoc.sourceforge.net |