Example #1
0
        public static Sha1 From(Binary binary, bool strict = true)
        {
            if (binary.Length != BinaryLength)
            {
                Expect.False(strict, "Value is not the SHA-1 binary length of 20 bytes: " + binary.ToText());

                return(None);
            }

            return(new Sha1(Hex.From(binary)));
        }
Example #2
0
 public Hex ToHex() => Hex.From(this);
Example #3
0
        public static Sha1 Compute(Binary value)
        {
            var hash = new SHA1CryptoServiceProvider().ComputeHash(value.ToBytes());

            return(Sha1.From(Hex.From(Binary.From(hash))));
        }
Example #4
0
 public static Sha1 From(string hex, bool strict = true)
 {
     return(new Sha1(Hex.From(hex, strict)));
 }
Example #5
0
        public static bool TryFrom(Binary binary, out Sha1 sha1)
        {
            sha1 = binary.Length == BinaryLength ? new Sha1(Hex.From(binary)) : null;

            return(sha1 != null);
        }