GetPass is a free, open source, cross-platform library to read passwords in console applications masking the input. It simply focus on getting the job done, with zero-dependencies and few lines of code.
It is licensed under MIT License.
If you like this project please don't forget to star it on GitHub or let me know with a tweet.
Install the GetPass Nuget package.
using GetPass;
var password = ConsolePasswordReader.Read();
or if you want to customize the prompt message:
var password = ConsolePasswordReader.Read("Key: ");
using System;
using GetPass;
namespace Sample
{
class Program
{
static void Main(string[] args)
{
var password = ConsolePasswordReader.Read();
Console.Write(password);
Console.WriteLine();
}
}
}
You can find the full example here.