90 lines
2.4 KiB
C#
90 lines
2.4 KiB
C#
using System;
|
|
using System.IO;
|
|
using Microsoft.Extensions.Configuration;
|
|
using app.Configuration;
|
|
|
|
namespace app.CredentialManager
|
|
{
|
|
class Program
|
|
{
|
|
static IConfiguration Configuration { get; set; }
|
|
|
|
static void Menu()
|
|
{
|
|
bool end = false;
|
|
while (!end)
|
|
{
|
|
Console.Clear();
|
|
Console.WriteLine("Credential Manager: \n");
|
|
Console.WriteLine("[1] Encode");
|
|
Console.WriteLine("[2] Decode");
|
|
Console.WriteLine("[x] Exit");
|
|
Console.Write("\n> ");
|
|
string input = Console.ReadLine();
|
|
switch (input)
|
|
{
|
|
case "1":
|
|
Console.Clear();
|
|
Encode();
|
|
break;
|
|
|
|
case "2":
|
|
Console.Clear();
|
|
Decode();
|
|
break;
|
|
|
|
case "x":
|
|
end = true;
|
|
Continue();
|
|
break;
|
|
|
|
case "X":
|
|
end = true;
|
|
Continue();
|
|
break;
|
|
|
|
default:
|
|
Console.WriteLine("Invalid input");
|
|
Continue();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
static void Continue()
|
|
{
|
|
Console.WriteLine("\n\nPress any key to continue...");
|
|
Console.ReadLine();
|
|
}
|
|
|
|
static void Main(string[] args)
|
|
{
|
|
Menu();
|
|
}
|
|
|
|
static void Encode()
|
|
{
|
|
Console.Write("String to encode: ");
|
|
string input = Console.ReadLine();
|
|
Console.WriteLine($"{input} encoded with Base64 is: {Base64.Encode(input)}");
|
|
Continue();
|
|
}
|
|
|
|
static void Decode()
|
|
{
|
|
Console.Write("String to decode: ");
|
|
string input = Console.ReadLine();
|
|
Console.WriteLine($"{input} decoded with Base64 is: {Base64.Decode(input)}");
|
|
Continue();
|
|
}
|
|
|
|
|
|
protected static SettingType GetTypedSettingsFromSection<SettingType>(string sectionName) where SettingType : new()
|
|
{
|
|
var settings = new SettingType();
|
|
Configuration.GetSection(sectionName).Bind(settings);
|
|
return settings;
|
|
}
|
|
}
|
|
}
|