Hi pals,
As I've told in a recent post, I'm starting out as a self-taught C++ programmer.
Yesterday (actually today at a VERY early hour, like 4 AM) I was playing around with my Atom and I made something very simple.
Basically, It's not really like Bitcoin Addresses (as they seem to have a length of 34 characters), mine generates random
potential addresses with 35 characters.
Check out the screen.It's been generating random
potential addresses for like 10 hours now and It stills do It, I made It so that It makes like 1000000000 addresses before finishing. I also made a condition that IF EVER two addresses are the same, the program should stop and It didn't (so every address made Is unique so far
).
I'm posting the code too! I want some feedback please.
#include
#include
#include
#include
#include
using namespace std;
class Hash
{
public:
Hash()
{
m_letters = "abcdefghijklmnopqrstvwxyzABCDEFGHIJKLMNOPQRSTVWXYZ0123456789:;";
m_hash = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
m_same = false;
m_hashes = 1000000000;
}
void generate()
{
default_random_engine engine(time(0));
uniform_int_distribution random(0, 61);
for(int i = 0; i < 35; i++)
{
m_random = random(engine);
m_hash[i] = m_letters[m_random];
}
cout << m_hash << endl;
}
void abortThis()
{
cout << "FOUND TWO HASHES WITH 100\% SAME DATA" << endl;
while(1)
{
}
}
void massGenerate()
{
default_random_engine engine(time(0));
uniform_int_distribution random(0, 61);
for(int i = 0; i < m_hashes; i++)
{
for(int i = 0; i < 35; i++)
{
m_random = random(engine);
m_hash[i] = m_letters[m_random];
}
for(auto c : m_massVerify)
{
if(m_hash == c)
abortThis();
}
m_list.push_back(m_hash);
m_massVerify.push_back(m_hash);
cout << m_hash << endl;
}
cout << "GENERATED " << m_hashes << " DIFFERENT HASHES SUCCESFULLY." << endl;
}
void show_all()
{
for(auto m_data : m_list)
cout << m_data << endl;
}
private:
int m_random;
unsigned int m_hashes;
string m_letters;
string m_hash;
string m_current;
bool m_same;
vector m_massVerify;
vector m_list;
};
int main()
{
Hash test;
test.massGenerate();
}
Specially SEE the default constructor of Hash class, and the function massGenerate.YOU CAN ALSO FIND THE CODE HERE BUT IT WON'T COMPILE ON ONLINE IDE.
http://cpp.sh/7g7oPLEASE,
Don't comment about that using namespace std; I know It's bad.
Don't comment about me using one file instead of a .cpp & .hpp, I know It's bad too.
Don't comment about variables name, I know It's good What I would REALLY BE INTERESTED IN, Is to find the piece of code that generates BITCOIN ADDRESSES in BITCOIN CORE!I'm COMPLETELY aware that the generated addresses doesn't start with 1 or 3. It has been done ON PURPOSE!