private void LoginButton_Click(object sender, EventArgs e)
        {
            string bt = GetBearerToken();

            if (bt.Length > 15)
            {
                WhirlpoolCryptoServiceProvider hash = new WhirlpoolCryptoServiceProvider();
                string hashedpass = BitConverter.ToString(hash.ComputeHash(Encoding.UTF8.GetBytes(PasswordInput.Text)));
                hashedpass = hashedpass.Replace("-", "");
                LoginUser(LoginInput.Text, hashedpass, bt);
                if (login != null)
                {
                    SignInUser();
                }
                else
                {
                    Error.ShowError("Podany login lub hasło jest błędne!");
                }
            }
            else
            {
                Error.ShowError("Wystąpił błąd podczas uwierzytelniania!");
                Environment.Exit(0);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Calculates the Whirlpool-hash of the given string
        /// </summary>
        /// <returns>Hexadecimal representation of the Whirlpool-hash.</returns>
        /// <param name="str">Input string.</param>
        public static string Whirlpool(string str)
        {
            var bytes = Encoding.ASCII.GetBytes(str);

            byte[] hash;

            // Let's use our own Whirlpool implementation
            using (var hasher = new WhirlpoolCryptoServiceProvider()) {
                hash = hasher.ComputeHash(bytes);
            }

            return(hash.ToHex());
        }