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))); }
public Hex ToHex() => Hex.From(this);
public static Sha1 Compute(Binary value) { var hash = new SHA1CryptoServiceProvider().ComputeHash(value.ToBytes()); return(Sha1.From(Hex.From(Binary.From(hash)))); }
public static Sha1 From(string hex, bool strict = true) { return(new Sha1(Hex.From(hex, strict))); }
public static bool TryFrom(Binary binary, out Sha1 sha1) { sha1 = binary.Length == BinaryLength ? new Sha1(Hex.From(binary)) : null; return(sha1 != null); }