diff --git a/.cproject b/.cproject
index f6ed9b7..e7bc0e7 100644
--- a/.cproject
+++ b/.cproject
@@ -24,7 +24,7 @@
-
diff --git a/crypto/encoding/base58.c b/crypto/encoding/base58.c
index 43ce920..1e1cc04 100644
--- a/crypto/encoding/base58.c
+++ b/crypto/encoding/base58.c
@@ -124,23 +124,22 @@ int libp2p_crypto_encoding_base58_decode(const char* b58, size_t base58_size, un
* @param base58_size the size of the results buffer
* @returns true(1) on success
*/
-//int libp2p_crypto_encoding_base58_encode(const unsigned char* binary_data, size_t binary_data_size, unsigned char* base58, size_t* base58_size)
-int libp2p_crypto_encoding_base58_encode(const unsigned char* data, size_t binsz, unsigned char** b58, size_t* b58sz)
+int libp2p_crypto_encoding_base58_encode(const unsigned char* binary_data, size_t binary_data_size, unsigned char** base58, size_t* base58_size)
{
- const uint8_t* bin = data;
+ const uint8_t* bin = binary_data;
int carry;
ssize_t i, j, high, zcount = 0;
size_t size;
- while (zcount < (ssize_t)binsz && !bin[zcount]) {
+ while (zcount < (ssize_t)binary_data_size && !bin[zcount]) {
++zcount;
}
- size = (binsz - zcount) * 138 / 100 + 1;
+ size = (binary_data_size - zcount) * 138 / 100 + 1;
uint8_t buf[size];
memset(buf, 0, size);
- for (i = zcount, high = size - 1; i < (ssize_t)binsz; ++i, high = j) {
+ for (i = zcount, high = size - 1; i < (ssize_t)binary_data_size; ++i, high = j) {
for (carry = bin[i], j = size - 1; (j > high) || carry; --j) {
carry += 256 * buf[j];
buf[j] = carry % 58;
@@ -151,20 +150,20 @@ int libp2p_crypto_encoding_base58_encode(const unsigned char* data, size_t binsz
for (j = 0; j < (ssize_t)size && !buf[j]; ++j)
;
- if (*b58sz <= zcount + size - j) {
- *b58sz = zcount + size - j + 1;
+ if (*base58_size <= zcount + size - j) {
+ *base58_size = zcount + size - j + 1;
memset(buf, 0, size);
return 0;
}
if (zcount) {
- memset(b58, '1', zcount);
+ memset(base58, '1', zcount);
}
for (i = zcount; j < (ssize_t)size; ++i, ++j) {
- (*b58)[i] = b58digits_ordered[buf[j]];
+ (*base58)[i] = b58digits_ordered[buf[j]];
}
- (*b58)[i] = '\0';
- *b58sz = i + 1;
+ (*base58)[i] = '\0';
+ *base58_size = i + 1;
memset(buf, 0, size);
return 1;
diff --git a/include/libp2p/multihash/multihash.h b/include/libp2p/multihash_old/multihash.h
similarity index 100%
rename from include/libp2p/multihash/multihash.h
rename to include/libp2p/multihash_old/multihash.h
diff --git a/multihash_old/multihash.c b/multihash_old/multihash.c
index ce71a1b..d342e98 100644
--- a/multihash_old/multihash.c
+++ b/multihash_old/multihash.c
@@ -1,8 +1,9 @@
+#include "../include/libp2p/multihash_old/multihash.h"
+
#include
#include
#include
-#include "libp2p/multihash/multihash.h"
#include "libp2p/crypto/encoding/base58.h"
diff --git a/test/multihash/test_multihash.h b/test/multihash/test_multihash.h
index 9996558..5a32e3b 100644
--- a/test/multihash/test_multihash.h
+++ b/test/multihash/test_multihash.h
@@ -1,7 +1,7 @@
#ifndef test_multihash_h
#define test_multihash_h
-#include "libp2p/multihash/multihash.h"
+#include "../../include/libp2p/multihash_old/multihash.h"
#include "libp2p/crypto/encoding/base58.h"
int test_multihash_encode() {