[#36] Client: Remove .net Range implementation

Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
Pavel Gross 2025-03-04 19:45:40 +03:00
parent 6988fcedae
commit 9364d60b96
3 changed files with 12 additions and 267 deletions

View file

@ -19,14 +19,14 @@ public static class Base58
if (buffer.Length < 4)
throw new FormatException();
byte[] checksum = buffer[0..(buffer.Length - 4)].Sha256().Sha256();
var check = buffer.AsSpan(0, buffer.Length - 4).ToArray();
byte[] checksum = check.Sha256().Sha256();
if (!buffer.AsSpan(buffer.Length - 4).SequenceEqual(checksum[..4].AsSpan()))
if (!buffer.AsSpan(buffer.Length - 4).SequenceEqual(checksum.AsSpan(0, 4)))
throw new FormatException();
var ret = buffer[..^4];
Array.Clear(buffer, 0, buffer.Length);
return ret;
return check;
}
public static string Base58CheckEncode(this ReadOnlySpan<byte> data)
@ -35,7 +35,7 @@ public static class Base58
Span<byte> buffer = stackalloc byte[data.Length + 4];
data.CopyTo(buffer);
checksum[..4].AsSpan().CopyTo(buffer[data.Length..]);
checksum.AsSpan(0, 4).CopyTo(buffer.Slice(data.Length));
var ret = Encode(buffer);
buffer.Clear();