Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add syntax highlighting to readme #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ Initialisation
Before you can use libbase58 for base58check, you must provide a SHA256
function. The required function signature is:

bool my_sha256(void *digest, const void *data, size_t datasz)
```c
bool my_sha256(void *digest, const void *data, size_t datasz)
```

Simply assign your function to b58_sha256_impl:

b58_sha256_impl = my_sha256;
```c
b58_sha256_impl = my_sha256;
```

This is only required if base58check is used. Raw base58 does not need SHA256.

Expand All @@ -19,7 +23,9 @@ Decoding Base58
Simply allocate a buffer to store the binary data in, and set a variable with
the buffer size, and call the b58tobin function:

bool b58tobin(void *bin, size_t *binsz, const char *b58, size_t b58sz)
```c
bool b58tobin(void *bin, size_t *binsz, const char *b58, size_t b58sz)
```

The "canonical" base58 byte length will be assigned to binsz on success, which
may be larger than the actual buffer if the input has many leading zeros.
Expand All @@ -34,7 +40,9 @@ Validating Base58Check
After calling b58tobin, you can validate base58check data using the b58check
function:

int b58check(const void *bin, size_t binsz, const char *b58, size_t b58sz)
```c
int b58check(const void *bin, size_t binsz, const char *b58, size_t b58sz)
```

Call it with the same buffers used for b58tobin. If the return value is
negative, an error occurred. Otherwise, the return value is the base58check
Expand All @@ -47,7 +55,9 @@ Encoding Base58
Allocate a string to store the base58 content, create a size_t variable with the
size of that allocation, and call:

bool b58enc(char *b58, size_t *b58sz, const void *data, size_t binsz)
```c
bool b58enc(char *b58, size_t *b58sz, const void *data, size_t binsz)
```

Note that you must pass a pointer to the string size variable, not the size
itself. When b58enc returns, the variable will be modified to contain the actual
Expand All @@ -62,5 +72,7 @@ Encoding Base58Check
Targeting base58check is done similarly to raw base58 encoding, but you must
also provide a version byte:

bool b58check_enc(char *b58c, size_t *b58c_sz, uint8_t ver,
const void *data, size_t datasz)
```c
bool b58check_enc(char *b58c, size_t *b58c_sz, uint8_t ver,
const void *data, size_t datasz)
```