コード例 #1
0
        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);
        }
コード例 #2
0
        private void Decrypt(int characters, byte bit, int last = 0)
        {
            combination = new byte[255];
            bool   result = false;
            string check  = "";

            while (!result)
            {
                for (int i = 0; i <= characters; i++)
                {
                    for (int j = 32; j < 137; j++)
                    {
                        combination[i] = Convert.ToByte(j);

                        /*for (int k = 32; k < 137; k++)
                         * {
                         *  combination[1] = Convert.ToByte(k);*/
                        check  = System.Text.ASCIIEncoding.ASCII.GetString(combination);
                        result = BlowfishCrypter.CheckPassword(check, encrypted);
                        if (result)
                        {
                            break;
                        }
                        //}
                    }
                }
            }
            if (result)
            {
                endtime = DateTime.Now;
                MessageBox.Show("Started at: " + starttime.ToString() + " Ended at: " + endtime.ToString());
                MessageBox.Show("Decrypted pass: "******"Done with character nr " + characters.ToString();
                    MessageBox.Show("Done with character nr " + characters.ToString());
                    Decrypt(characters, bit, last);
                }
                else
                {
                    bit++;
                    Decrypt(characters, bit);
                }
            }
        }
コード例 #3
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);
        }
コード例 #4
0
        public User ValidateUser(string email, string password)
        {
            var user = ((IUserRepository)_repository).GetByMail(email);

            if (user == null)
            {
                return(null);
            }
            if (BlowfishCrypter.CheckPassword(password, user.Password))
            {
                return(user);
            }
            return(null);
        }
コード例 #5
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");
        }