Cryptography/CafeLib.Cryptography/Base58CheckEncoder.cs
/// <summary>
/// Appends first 4 bytes of double SHA256 hash to bytes before standard Base58 encoding.
/// </summary>
/// <param name="bytes"></param>
/// <returns></returns>
Appends first 4 bytes of double SHA256 hash to bytes before standard Base58 encoding.
Appends first 4 bytes of double SHA256 hash to bytes before standard Base58 encoding .
public string Encode(byte[] bytes)
        {
            var span = new ReadOnlyByteSpan(bytes);
            var checksum = span.Hash256();
            var buf = new byte[span.Length + 4];
            span.CopyTo(buf);
            checksum.Span[..4].CopyTo(buf.AsSpan()[span.Length..]);
            return Base58Encoder.Encode(buf);
        }
public string Encode ( byte [ ] bytes ) { var span = new ReadOnlyByteSpan ( bytes ) ; var checksum = span . Hash256 ( ) ; var buf = new byte [ span . Length + 4 ] ; span . CopyTo ( buf ) ; checksum . Span [ .. 4 ] . CopyTo ( buf . AsSpan ( ) [ span . Length .. ] ) ; return Base58Encoder . Encode ( buf ) ; }
Appends first 4 bytes of double SHA256 hash to bytes before standard Base58 encoding.
Appends first 4 bytes of double SHA256 hash to bytes before standard Base58 encoding .
None
bytes
byte[]
None