Home > Net >  Change Spectre.Console mask character for secure input
Change Spectre.Console mask character for secure input

Time:08-30

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)?

CodePudding user response:

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

  • Related