public void Base32SameAsUlidGenerated() { var ulid = System.Ulid.Parse("0123456789ABCDEFGHJKMNPQRS"); var b32 = ulid.ToString(); var b = ulid.ToByteArray(); var actual = new byte[b.Length]; CliUtil.ConvertBase32ToBytes(b32, actual, 2); actual.Should().BeEquivalentTo(b); }
public void Base32() { var pairs = new KeyValuePair <string, byte[]>[] { new KeyValuePair <string, byte[]>("00000000", new byte[] { 0, 0, 0, 0, 0 }), new KeyValuePair <string, byte[]>("ZZZZZZZZ", new byte[] { 0xff, 0xff, 0xff, 0xff, 0xff }), new KeyValuePair <string, byte[]>(new string('1', 8), new byte[] { 0x08, 0x42, 0x10, 0x84, 0x21 }) }; foreach (var pair in pairs) { var buf = new byte[5]; CliUtil.ConvertBase32ToBytes(pair.Key, buf, 0); buf.Should().BeEquivalentTo(pair.Value); } }