[InlineData("8tWhXW5oUwtPd9d3FnjuLP1NozN3vc45rmsoWEEfrZL1L6gi9dqi1YkZu5iHb2HJ8WbZaaKAyNWWRAa8yaxMkGKJmX", "hello world")] // sha3_512 public void TestVerify(string mhs, string data) { var mh = Multihash.Parse(mhs); var bytes = Encoding.UTF8.GetBytes(data); Assert.True(mh.Verify(bytes)); }
public void VerifyRoundTrip(HashType type) { var rand = new Random(Environment.TickCount); var bytes = new byte[rand.Next(1024, 4096)]; rand.NextBytes(bytes); var mh = Multihash.Sum(type, bytes, type == HashType.ID ? bytes.Length : -1); var str = mh.ToString(); var mh2 = Multihash.Parse(str); Assert.True(mh2.Verify(bytes)); }
public static Cid Decode(string v) { if (v.Length < 2) { throw new ArgumentException("cid too short", nameof(v)); } if (v.Length == 46 && v.Substring(0, 2) == "Qm") { return(new Cid(Multihash.Parse(v))); } return(Cast(Multibase.Decode(v))); }
public async Task VerifyRoundTripAsync(HashType type) { var rand = new Random(Environment.TickCount); var bytes = new byte[rand.Next(1024, 4096)]; rand.NextBytes(bytes); var mh = await Multihash.SumAsync(type, bytes); var str = mh.ToString(); var mh2 = Multihash.Parse(str); Assert.True(await mh2.VerifyAsync(bytes)); }