Function inttolenhex

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

    Parameters

    • n: number

      ASN.1 length value.

    Returns string

    an hexadecimal string of ASN.1 length octet. For ASN.1 BER indefinite length -1, returns "80"

    See

    lenhextoint

    Description

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

    Example

    inttolenhex(16) -> "10"
    inttolenhex(256) -> "81ff"
    inttolenhex(-1) -> "80"
    inttolenhex(1147) -> "82047b"