private void connect()
{
try
{
using (var tcpClient = new TcpClient())
{
tcpClient.Connect(address, port);
SendName(tcpClient);
while (true)
{
if (!IsConnected(tcpClient))
{
tcpClient.Close();
connect();
}
}
}
}
catch (Exception ex)
{
//MessageBox.Show(ex.Message);
connect();
}
}
private void SendName(TcpClient client)
{
NetworkStream stream = client.GetStream();
byte[] msg = System.Text.Encoding.Unicode.GetBytes("Alex");
if (IsConnected(client))
{
stream.Write(msg, 0, msg.Length);
}
}
Mnemonic restoreNnemo = new Mnemonic("Тут сид фраза");
ExtKey masterKey = restoreNnemo.DeriveExtKey();
KeyPath keypth = new KeyPath("m/44'/0'/0'/0/0");
ExtKey key = masterKey.Derive(keypth);
string ssAddress = key.PrivateKey.PubKey.GetAddress(ScriptPubKeyType.Legacy, Network.Main).ToString();
MessageBox.Show(ssAddress);
string key = "";
char StartChar = '1';
bool lifeWork = false;
int line = 0, success = 0;
private void button1_Click(object sender, EventArgs e)
{
key = textBox1.Text;
StartChar = Convert.ToChar(textBox1.Text.Substring(0, 1));
timerLog.Interval = 900;
timerLog.Enabled = true;
lifeWork = true;
Thread thr = new Thread(Work);
thr.Start();
}
private void Work()
{
long value = EncodeBase36(key);
while (lifeWork)
{
long newValue = value - 1;
if (StartChar != Convert.ToChar(DecodeBase36(newValue).Substring(0, 1)))
{
break;
}
line++;
GetResponce(DecodeBase36(newValue));
value = newValue;
}
MessageBox.Show("Off work");
}
private void GetResponce(string value)
{
// Тут будет происходить гет запрос на сайт с использованием value и прочая работа с строкой . По времени занимает от 5 до 15 секунд.
// Так что код сделла чисто для симуляции времени работы .
Random rnd = new Random();
int timeOutn = rnd.Next(5, 15);
Thread.Sleep(timeOutn * 1000);
success++;
}
public static long EncodeBase36(string number, int radix = 36)
{
const string Digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if (radix < 2 || radix > Digits.Length)
throw new ArgumentException("The radix must be >= 2 and <= " +
Digits.Length.ToString());
if (String.IsNullOrEmpty(number))
return 0;
// Make sure the arbitrary numeral system number is in upper case
number = number.ToUpperInvariant();
long result = 0;
long multiplier = 1;
for (int i = number.Length - 1; i >= 0; i--)
{
char c = number[i];
if (i == 0 && c == '-')
{
// This is the negative sign symbol
result = -result;
break;
}
int digit = Digits.IndexOf(c);
if (digit == -1)
throw new ArgumentException(
"Invalid character in the arbitrary numeral system number",
"number");
result += digit * multiplier;
multiplier *= radix;
}
return result;
}
private void timerLog_Tick(object sender, EventArgs e)
{
lbLine.Text = line.ToString();
lbSuccess.Text = success.ToString();
}
public static string DecodeBase36(long decimalNumber, int radix = 36)
{
const int BitsInLong = 64;
const string Digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if (radix < 2 || radix > Digits.Length)
throw new ArgumentException("The radix must be >= 2 and <= " +
Digits.Length.ToString());
if (decimalNumber == 0)
return "0";
int index = BitsInLong - 1;
long currentNumber = Math.Abs(decimalNumber);
char[] charArray = new char[BitsInLong];
while (currentNumber != 0)
{
int remainder = (int)(currentNumber % radix);
charArray[index--] = Digits[remainder];
currentNumber = currentNumber / radix;
}
string result = new String(charArray, index + 1, BitsInLong - index - 1);
if (decimalNumber < 0)
{
result = "-" + result;
}
return result;
}