public void Sha384Hash_GetHash_Null_3() { IHash hashAlgo = new Sha384Hash(); Action action = () => hashAlgo.GetHash(null as FileInfo); action.Should().Throw <ArgumentNullException>(); }
public void Sha384Hash_GetHash_Empty() { IHash hashAlgo = new Sha384Hash(); Action action = () => hashAlgo.GetHash(string.Empty); action.Should().Throw <ArgumentNullException>(); }
public void Sha384Hash_GetHash_Valid_2() { IHash hashAlgo = new Sha384Hash(); HashResult hashResult = hashAlgo.GetHash(Data.ExpectedHashFilePath); hashResult.Algorithm.Should().Be(Hashing.ExpectedSha384Algorithm); hashResult.Value.Should().Be(Hashing.ExpectedSha384Hash); }
public void Sha384Hash_GetHash_Valid_1() { IHash hashAlgo = new Sha384Hash(); using FileStream fileStream = new(Data.ExpectedHashFilePath, FileMode.Open, FileAccess.Read, FileShare.Read); HashResult hashResult = hashAlgo.GetHash(fileStream); hashResult.Algorithm.Should().Be(Hashing.ExpectedSha384Algorithm); hashResult.Value.Should().Be(Hashing.ExpectedSha384Hash); }
/// <summary> /// 散列服务创造器 /// </summary> /// <param name="type"></param> /// <returns></returns> public IHash CreateHash(Type type) { IHash hash; switch (type) { case Type.Md5: hash = new MD5Hash(); break; case Type.Sha1: hash = new Sha1Hash(); break; case Type.Sha256: hash = new Sha256Hash(); break; case Type.Sha384: hash = new Sha384Hash(); break; case Type.Sha512: hash = new Sha512Hash(); break; case Type.RipEmd160: hash = new RipEmd160Hash(); break; default: hash = new MD5Hash(); break; } return(hash); }