Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Created October 1, 2024 16:49
SecurityManager after Extract Call & Override
using System;
namespace LegacySecurityManager;
public class SecurityManager
{
public static void CreateUser()
{
new SecurityManager().DoCreateUser();
}
public void DoCreateUser()
{
Notify("Enter a username");
var username = Read();
Notify("Enter your full name");
var fullName = Read();
Notify("Enter your password");
var password = Read();
Notify("Re-enter your password");
var confirmPassword = Read();
if (password != confirmPassword)
{
Notify("The passwords don't match");
return;
}
if (password.Length < 8)
{
Notify("Password must be at least 8 characters in length");
return;
}
// Encrypt the password (just reverse it, should be secure)
char[] array = password.ToCharArray();
Array.Reverse(array);
Notify($"Saving Details for User ({username}, {fullName}, {new string(array)})\n");
}
protected virtual string Read()
{
return Console.ReadLine();
}
protected virtual void Notify(string message)
{
Console.WriteLine(message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment