mirror of
https://github.com/eosswedenorg/antelope-keygen
synced 2026-06-18 04:00:03 +02:00
search: define a key_result struct and store position and length in public key for the word found.
This commit is contained in:
parent
8c8d88c631
commit
075144c72b
4 changed files with 26 additions and 14 deletions
|
|
@ -3,22 +3,29 @@
|
|||
#include "WIF.h"
|
||||
#include "key_search_helpers.h"
|
||||
|
||||
void key_search_result(const std::string& word, const struct ec_keypair* pair) {
|
||||
void key_search_result(const struct ec_keypair* key, const struct key_result* result) {
|
||||
|
||||
std::string pub = wif_pub_encode(key->pub);
|
||||
std::string word = pub.substr(result->pos, result->len);
|
||||
|
||||
std::cout << "----" << std::endl;
|
||||
std::cout << "Found: " << word << std::endl;
|
||||
wif_print_key(pair);
|
||||
|
||||
std::cout << "Public: " << pub << std::endl;
|
||||
std::cout << "Private: " << wif_priv_encode(key->secret) << std::endl;
|
||||
}
|
||||
|
||||
bool key_contains_word(const struct ec_keypair* key, const strlist_t& word_list, std::string& word) {
|
||||
bool key_contains_word(const struct ec_keypair* key, const strlist_t& word_list, struct key_result *result) {
|
||||
|
||||
// skip first 3 chars, as those are always "EOS"
|
||||
std::string pubstr = wif_pub_encode(key->pub).substr(3);
|
||||
strtolower(pubstr);
|
||||
|
||||
for(auto const& w: word_list) {
|
||||
if (pubstr.find(w) != std::string::npos) {
|
||||
word = w;
|
||||
size_t p = pubstr.find(w);
|
||||
if (p != std::string::npos) {
|
||||
result->pos = p + 3;
|
||||
result->len = w.length();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue