diff --git a/c/opendht.cpp b/c/opendht.cpp index fb28b7218c096ab62a0fec452aacfb881286bf04..99759edaacca9c584e6c3627b9e86d34441ab275 100644 --- a/c/opendht.cpp +++ b/c/opendht.cpp @@ -22,6 +22,11 @@ void dht_infohash_random(dht_infohash* h) *reinterpret_cast<dht::InfoHash*>(h) = dht::InfoHash::getRandom(); } +void dht_infohash_get(dht_infohash* h, const uint8_t* dat, size_t dat_size) +{ + *reinterpret_cast<dht::InfoHash*>(h) = dht::InfoHash::get(dat, dat_size); +} + bool dht_infohash_is_zero(const dht_infohash* h) { return static_cast<bool>(*reinterpret_cast<const dht::InfoHash*>(h)); } diff --git a/c/opendht_c.h b/c/opendht_c.h index de69a013cd77542c51b2d5086336bf6f3ff8ccc2..e4b0180c480f35d0793996f50f7e45f70cdc61bd 100644 --- a/c/opendht_c.h +++ b/c/opendht_c.h @@ -37,6 +37,7 @@ struct OPENDHT_C_PUBLIC dht_infohash { uint8_t d[HASH_LEN]; }; typedef struct dht_infohash dht_infohash; OPENDHT_C_PUBLIC void dht_infohash_zero(dht_infohash* h); OPENDHT_C_PUBLIC void dht_infohash_random(dht_infohash* h); +OPENDHT_C_PUBLIC void dht_infohash_get(dht_infohash* h, const uint8_t* dat, size_t dat_size); OPENDHT_C_PUBLIC const char* dht_infohash_print(const dht_infohash* h); OPENDHT_C_PUBLIC bool dht_infohash_is_zero(const dht_infohash* h); @@ -63,7 +64,7 @@ typedef struct dht_privatekey dht_privatekey; OPENDHT_C_PUBLIC dht_privatekey* dht_privatekey_generate(unsigned key_length_bits); OPENDHT_C_PUBLIC dht_privatekey* dht_privatekey_import(const uint8_t* dat, size_t dat_size, const char* password); OPENDHT_C_PUBLIC dht_publickey* dht_privatekey_get_publickey(const dht_privatekey*); -OPENDHT_C_PUBLIC void dht_privatekey_delete(dht_privatekey* pk); +OPENDHT_C_PUBLIC void dht_privatekey_delete(dht_privatekey*); // dht::crypto::Certificate struct OPENDHT_C_PUBLIC dht_certificate;