Пример #1
0
        public static string ToString(byte[] hash, HashEncodings encoding)
        {
            switch (encoding)
            {
            case HashEncodings.HexLowerCase: return(ToHexString(hash).ToLower());

            case HashEncodings.HexUpperCase: return(ToHexString(hash));

            case HashEncodings.BlockyHex: return(ToHexString(hash, "-").ToLower());

            case HashEncodings.Base64: return(ToBase64String(hash));

            default: return("-");
            }
        }
Пример #2
0
        protected void UpdateUiElements()
        {
            lock (this.hashUiElements)
            {
                HashEncodings encoding = GetSelectedEncoding();
                foreach (KeyValuePair <HashAlgorithms, AlgorithmUiElements> kvp in this.hashUiElements)
                {
                    kvp.Value.ComputeButton.Enabled = (this.selectedFile != null && kvp.Value.State == AlgorithmStates.None);
                    switch (kvp.Value.State)
                    {
                    case AlgorithmStates.None:
                        if (this.selectedFile != null)
                        {
                            kvp.Value.HashBox.Text = "Press compute -->";
                        }
                        else
                        {
                            kvp.Value.HashBox.Text = "";
                        }
                        break;

                    case AlgorithmStates.Issued:
                        kvp.Value.HashBox.Text = "[Waiting for other computation]";
                        break;

                    case AlgorithmStates.Computing:
                        kvp.Value.HashBox.Text = "[Computation running...]";
                        break;

                    case AlgorithmStates.Ready:
                        kvp.Value.HashBox.Text = HashConverter.ToString(kvp.Value.Hash, encoding);
                        break;
                    }
                }
            }
        }