コード例 #1
0
        public static BinaryHashData Parse(string value)
        {
            BinaryHashData result = new BinaryHashData();

            if (value == null || (value = value.Trim()).Length == 0)
            {
                return(result);
            }
            for (int i = 0; i < value.Length; i++)
            {
                if (Char.IsControl(value[i]) || Char.IsWhiteSpace(value[i]) || value[i] == ':' || value[i] == '-' || value[i] == '{' || value[i] == '}')
                {
                    continue;
                }
                if (i == value.Length - 1)
                {
                    throw new FormatException("Input string was not in a correct format.");
                }
                byte b = Byte.Parse(value.Substring(i, 2));
                i++;
                if (b < 16 && value[i] != '0')
                {
                    throw new FormatException("Input string was not in a correct format.");
                }
                result._data.Add(b);
            }
            return(result);
        }
コード例 #2
0
        public BinaryHashData GetHash(System.Security.Cryptography.HashAlgorithm provider)
        {
            BinaryHashData result = new BinaryHashData();

            if (_data.Count > 0)
            {
                result._data.AddRange(provider.ComputeHash(_data.ToArray()));
            }
            return(result);
        }