Function namearraytobinstr

  • convert array of names to bit string

    Parameters

    • namearray: string[]

      array of name string

    • namedb: Record<string, number>

      associative array of name and value

    Returns string

    binary string (ex. "110001")

    See

    binstrtonamearray

    Description

    This function converts from an array of names to a binary string. DB value bit will be set. Note that ordering of namearray items will be ignored. This function may be useful to implement ASN.1 BitString such as KeyUsage.

    Example

    const db: Record<string, number> = { a: 0, b: 3, c: 8, d: 9, e: 17, f: 19 };
    namearraytobinstr(['a', 'c', 'd'], db) -> '1000000011'
    namearraytobinstr(['c', 'b'], db) -> '000100001'