Function lenhextoint

  • convert ASN.1 TLV length octet to ASN.1 length value

    Parameters

    • hL: string

      hexadecimal string of ASN.1 length octet

    Returns number

    ASN.1 length value. For ASN.1 BER indefinite length (i.e. "80"), returns -1

    See

    inttolenhex

    Description

    This function converts an ASN.1 TLV length octet to ASN.1 TLV length value. When the input is "80" which means ASN.1 BER indefinite length, it returns a special value -1.

    Example

    lenhextoint("10") -> 16
    lenhextoint("81ff") -> 256
    lenhextoint("80") -> -1 // indefinite length
    lenhextoint("82047b") -> 1147