public bool CheckPassword(string deviceId, string password) { BlowfishCrypter crypter = new BlowfishCrypter(); string existingPassword = GenericData.GetPlayerData(deviceId, "password").ToUTF8String(); string checkedPassword = crypter.Crypt(password, existingPassword); return(existingPassword == checkedPassword); }
public bool EncryptUserPassword(string deviceId, string password) { var options = new CrypterOptions() { { CrypterOption.Rounds, Configuration["PasswordRounds"] } }; BlowfishCrypter crypter = new BlowfishCrypter(); var salt = crypter.GenerateSalt(options); var results = crypter.Crypt(password, salt); GenericData.SetPlayerData(deviceId, "password", results); return(true); }
private static void PwdSpeedTest() { Log.WriteLog("Determining the correct value for Rounds on this computer for saving passwords..."); System.Diagnostics.Stopwatch encryptTimer = new System.Diagnostics.Stopwatch(); int rounds = 6; while (encryptTimer.ElapsedMilliseconds < 250) { rounds++; var options = new CrypterOptions() { { CrypterOption.Rounds, rounds } }; encryptTimer.Restart(); BlowfishCrypter crypter = new BlowfishCrypter(); var salt = crypter.GenerateSalt(options); var results = crypter.Crypt("anythingWillDo", salt); encryptTimer.Stop(); Log.WriteLog("Time with Rounds:" + rounds + ": " + encryptTimer.ElapsedMilliseconds + "ms"); } Log.WriteLog("Suggestion: Set the PasswordRounds configuration variable to " + rounds + " in PraxisMapper's appsettings.json file"); }