|
|
|
@ -7,10 +7,6 @@ using System.Text;
|
|
|
|
|
// load database
|
|
|
|
|
PersistenceManager manager = new(new Stub());
|
|
|
|
|
Database db = manager.LoadDatabaseData();
|
|
|
|
|
foreach(User user in db.GetUserList())
|
|
|
|
|
{
|
|
|
|
|
user.SetPassword(GetSHA256Hash(user.GetPassword()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// initialization zone==============================================================================
|
|
|
|
@ -139,22 +135,6 @@ List<string>? choix_couleur()
|
|
|
|
|
return colorList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static string GetSHA256Hash(string input)
|
|
|
|
|
{
|
|
|
|
|
using (SHA256 sha256Hash = SHA256.Create())
|
|
|
|
|
{
|
|
|
|
|
byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
|
|
|
|
|
|
|
|
|
|
StringBuilder builder = new StringBuilder();
|
|
|
|
|
for (int i = 0; i < bytes.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
builder.Append(bytes[i].ToString("x2"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return builder.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (menu)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("\n|--------------------------------------|");
|
|
|
|
@ -190,7 +170,6 @@ while (menu)
|
|
|
|
|
Console.WriteLine("\nEntrez un password :");
|
|
|
|
|
string? password = Console.ReadLine();
|
|
|
|
|
if (password == null) { continue; }
|
|
|
|
|
password = GetSHA256Hash(password);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
u = db.GetUser(nom);
|
|
|
|
@ -202,7 +181,7 @@ while (menu)
|
|
|
|
|
}
|
|
|
|
|
if (!connection)
|
|
|
|
|
{
|
|
|
|
|
if (Database.ComparePassword(u, password))
|
|
|
|
|
if (Database.ComparePassword(u, password.GetHashCode().ToString()))
|
|
|
|
|
{
|
|
|
|
|
u.SetIsConnected(true);
|
|
|
|
|
Console.WriteLine("\nConnection réussie !\n");
|
|
|
|
@ -234,8 +213,7 @@ while (menu)
|
|
|
|
|
}
|
|
|
|
|
catch (AlreadyUsedException)
|
|
|
|
|
{
|
|
|
|
|
password = GetSHA256Hash(password);
|
|
|
|
|
u = new User(nom, "", password);
|
|
|
|
|
u = new User(nom, "", password.GetHashCode().ToString());
|
|
|
|
|
db.AddUser(u);
|
|
|
|
|
db.GetUser(nom).SetIsConnected(true);
|
|
|
|
|
Console.WriteLine("\nConnection réussie !\n");
|
|
|
|
@ -548,8 +526,7 @@ while (u.GetIsConnected())
|
|
|
|
|
Console.WriteLine("\nLe mot de passe doit contenir au moins 8 caractères.\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
wantedNewPassword = GetSHA256Hash(wantedNewPassword);
|
|
|
|
|
if(wantedNewPassword == u.GetPassword()){
|
|
|
|
|
if(wantedNewPassword.GetHashCode().ToString() == u.GetPassword()){
|
|
|
|
|
Console.WriteLine("\nLe nouveau mot de passe doit être différent de l'ancien.\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|