-1
我對C#相當陌生,而且似乎無法找到我在線尋找的內容。我需要使用用戶名和密碼功能創建一個應用程序"Authenticate"
。良好的憑證,如"Admin, Pa$$w0rd"
等將被保存在該CSV文件中,加載到我的Authenticator.cs中的字典中,然後通過用戶在表單上的文本框中提供的任何內容進行驗證。然後在按鈕上將輸入與CSV進行比較並進行身份驗證。希望我已經夠清楚了。從CSV文件加載值到Windows Form C#字典
到目前爲止,我設法創建窗體和文本框等,以及作爲認證級(從我的控制檯應用程序,下面的代碼複製,沒有改變的形式還)
class Authenticator
{
//Created a Private Dictionary to hide contents
private Dictionary<string, string> Users = new Dictionary<string, string>();
public Authenticator()
{
//Details - adding keys and values to dictionary
Users.Add("Administrator", "Pa$$w0rd");
Users.Add("Admin", "password");
Users.Add("root", "secure");
}
//Public Bool to Validate dictionary data
public bool ValidateCredentials(string username, string password) //Focuses on the username key and password value
{
return Users.Any(entry => entry.Key == username && entry.Value == password);
//When entered username matches the key and password input matches the key
//Then bool is true
}
}
}
所以,如果有人知道:
- 我怎樣才能CSV數據加載到一個字典在我的課
- 比較輸入數據VS羅亞代理數據
- 製作一個日誌文件(csv),用於記錄日期時間,使用用戶名和密碼的每個
"Authentication"
嘗試。
很多謝謝。
兩件事情:[CSVHelper](https://www.nuget.org/packages/CsvHelper/)另一種是在明文口令的存儲一個沒有沒有。 – t0mm13b
以純文本形式存儲密碼?您應該考慮對此的安全影響。 – disklosr