Search code examples
c#.netconsoledata-maskingspectre.console

Change Spectre.Console mask character for secure input


I'm using the Spectre.Console library's password feature. It echos asterisks (***) instead of the secret text.

Is it possible to change the mask character, or to disable it completely (sudo style)?


Solution

  • It's not possible, once the property IsSecret is set via Secret() language extension method and the prompt is shown as shown below ShowAsync is executed which there is nothing to do what you are asking.

    public static string AskPassword()
    {
        return AnsiConsole.Prompt(
            new TextPrompt<string>("[thistle1]Password[/]?")
                .PromptStyle("grey50")
                .Secret());
    }
    

    See also source method