Function inttobitstr

  • convert from integer value to hexadecimal string of ASN.1 BitString value with unused bit

    Parameters

    • n: number

      integer value of ASN.1 BitString

    Returns string | null

    hexadecimal string of ASN.1 BitString value with unused bit

    See

    bitstrtoint

    Description

    This function converts from an integer value to hexadecimal string of ASN.1 BitString value with unused bit.
    When "n" is not non-negative number, this returns null

    Example

    // 25 -> 11001b -> 11001000b unusedbit=03 -> 0xc8 unusedbit=03 -> "03c8"
    inttobitstr(25) -> "03c8"
    inttobitstr(-3) -> null
    inttobitstr("abc") -> null
    inttobitstr(parseInt("11001", 2)) -> "03c8"
    inttobitstr(parseInt("101", 2)) -> "05a0"
    inttobitstr(parseInt("101000001", 2)) -> "07a080"