mirror of
https://github.com/eosswedenorg/antelope-keygen
synced 2026-06-18 04:00:03 +02:00
key_search: split key_search() function into key_search() and key_search_n()
This commit is contained in:
parent
f4e2b1e162
commit
77d63a5c36
3 changed files with 29 additions and 15 deletions
|
|
@ -25,22 +25,33 @@ static void key_result(const std::string& word, const struct ec_keypair* pair) {
|
|||
wif_print_key(pair);
|
||||
}
|
||||
|
||||
void key_search(strlist_t word_list, size_t n) {
|
||||
bool key_search(struct ec_keypair* key, std::string& word, const strlist_t& word_list) {
|
||||
|
||||
std::string pubstr;
|
||||
|
||||
ec_generate_key(key);
|
||||
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;
|
||||
}
|
||||
|
||||
void key_search_n(const strlist_t& word_list, size_t n) {
|
||||
|
||||
size_t count = 0;
|
||||
struct ec_keypair pair;
|
||||
|
||||
while (count < n) {
|
||||
std::string pubstr;
|
||||
ec_generate_key(&pair);
|
||||
pubstr = wif_pub_encode(pair.pub);
|
||||
strtolower(pubstr);
|
||||
|
||||
for(auto const& word: word_list) {
|
||||
if (pubstr.find(word) != std::string::npos) {
|
||||
key_result(word, &pair);
|
||||
count++;
|
||||
}
|
||||
std::string word;
|
||||
if (key_search(&pair, word, word_list)) {
|
||||
key_result(word, &pair);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue