Ejemplo n.º 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)));
        }
Ejemplo n.º 2
0
 public Hex ToHex() => Hex.From(this);
Ejemplo n.º 3
0
        public static Sha1 Compute(Binary value)
        {
            var hash = new SHA1CryptoServiceProvider().ComputeHash(value.ToBytes());

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

            return(sha1 != null);
        }