Example #1
0
        public static bool TryFrom(Binary binary, out Sha1 sha1)
        {
            sha1 = binary.Length == BinaryLength ? new Sha1(Hex.From(binary)) : null;

            return(sha1 != null);
        }
Example #2
0
        public static bool TryFrom(string hex, out Sha1 sha1)
        {
            sha1 = Hex.TryFrom(hex, out var parsedHex) && parsedHex.TextLength == HexLength ? new Sha1(parsedHex) : null;

            return(sha1 != null);
        }
Example #3
0
        public static bool TryFrom(Hex hex, out Sha1 sha1)
        {
            sha1 = hex.TextLength == HexLength ? new Sha1(hex) : null;

            return(sha1 != null);
        }
Example #4
0
 Sha1(Hex hex)
 {
     _hex = hex;
 }
Example #5
0
 public static Sha1 Compute(Hex value) =>
 Compute(value.ToBinary());
Example #6
0
        //
        // Compute
        //

        public static Sha1 Compute(Binary value)
        {
            var hash = new SHA1CryptoServiceProvider().ComputeHash(value.ToBytes());

            return(From(Hex.From(Binary.From(hash))));
        }