diff --git a/src/key_search_helpers.cpp b/src/key_search_helpers.cpp index 869e64f..82d625e 100644 --- a/src/key_search_helpers.cpp +++ b/src/key_search_helpers.cpp @@ -9,3 +9,17 @@ void key_search_result(const std::string& word, const struct ec_keypair* pair) { std::cout << "Found: " << word << std::endl; wif_print_key(pair); } + +bool key_contains_word(const struct ec_keypair* key, const strlist_t& word_list, std::string& word) { + + std::string pubstr = wif_pub_encode(key->pub); + strtolower(pubstr); + + for(auto const& w: word_list) { + if (pubstr.find(w) != std::string::npos) { + word = w; + return true; + } + } + return false; +} diff --git a/src/key_search_helpers.h b/src/key_search_helpers.h index 70ee1b4..66d4291 100644 --- a/src/key_search_helpers.h +++ b/src/key_search_helpers.h @@ -24,9 +24,13 @@ #ifndef KEY_SEARCH_HELPSER_H #define KEY_SEARCH_HELPERS_H -#include +#include "string.h" #include "ec.h" void key_search_result(const std::string& word, const struct ec_keypair* pair); +// Check if any word in appears in 's public key. +// returns true if a word was found (stored in ), false otherwise. +bool key_contains_word(const struct ec_keypair* key, const strlist_t& word_list, std::string& word); + #endif /* KEY_SEARCH_HELPERS_H */