Skip to content

Instantly share code, notes, and snippets.

@vova-lantsov-dev
Last active March 20, 2019 21:22
Show Gist options
  • Save vova-lantsov-dev/19c9fd5d8e44a3a52bb837c3e58e9d4d to your computer and use it in GitHub Desktop.
Save vova-lantsov-dev/19c9fd5d8e44a3a52bb837c3e58e9d4d to your computer and use it in GitHub Desktop.
new Thread(() =>
{
for (var ine = 0; ine < 2; ine++)
{
if (ine == 1)
byteprob = Instruments_for_bytes.Reverse(byteprob)
var bytestring = BitConverter.ToString(ine == 0 ? byteprob : Instruments_for_bytes.Reverse(byteprob));
result = File.ReadAllBytes(textBox3.Text);
for (var i = 0; i <= 7; i++)
{
progressBar1.Invoke(() => progressBar1.Value += 6);
if (i > 0)
bytestream = Instruments_for_bytes.ShiftLeft(bytestream);
var k = Instruments_for_bytes.IndexOf(bytestream, byteprob);
if (k[0] > -1)
{
var sb = new StringBuilder();
sb.Append(Environment.NewLine);
var values = new[]
{
$"Паттерн байт = {bytestring}",
$"Период = {k[0]}",
$"Байтовый сдвиг = {k[1]}",
$"Битовый сдвиг: {i}",
$"Разворот байт: {(ine == 0 ? "Нет" : "Есть")}"
};
sb.AppendJoin(Environment.NewLine, values);
richTextBox1.Invoke(() =>
{
richTextBox1.Text += sb.ToString();
progressBar1.Value = 100;
});
result = new byte[bytestream.Length - k[1]];
Array.Copy(ine == 0 ? Instruments_for_bytes.Reverse(bytestream) : bytestream, k[1], result, 0, result.Length);
finded = true;
break;
}
else if (ine == 1 && i == 7)
{
progressBar1.Invoke(() =>
{
progressBar1.Value = 100;
richTextBox1.Text += string.Concat(Environment.NewLine, "Паттерн не найден");
});
break;
}
}
}).Start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment