Mask a string with a specified character

maskString('1234567890', 6) // '******7890'
maskString('1234567890', 6, 'x') // 'xxxxxx7890'
maskString('12345', 6) // '*****'
  • Parameters

    • string: string

      The string to mask

    • maskLength: number

      The length of the string to mask

    • mask: string = '*'

      The character to use for masking. Default is '*'

    Returns string

    The masked string