Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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");
        }