M
M
Moolzv Rivers2019-10-28 20:32:26
C++ / C#
Moolzv Rivers, 2019-10-28 20:32:26

Why is it incorrectly written to textBox?

private void metroButton3_Click(object sender, EventArgs e)
        {
            string text = textBox1.Text;
            textBox1.Text = "";

            String[] textOnChars = text.Split(new char[] {'\n'}, StringSplitOptions.RemoveEmptyEntries);
            
            for (int i = 0; i < textOnChars.Length; i++)
            {
                string crypted = EncryptText(textOnChars[i]);
                textBox1.Text += textOnChars[i] + " - " + crypted + "\n";
            }
        }

        public static string EncryptText(string originalPassword)
        {
            Byte[] originalBytes;
            Byte[] encodedBytes;
            MD5 md5;
            md5 = new MD5CryptoServiceProvider();
            originalBytes = ASCIIEncoding.Default.GetBytes(originalPassword);
            encodedBytes = md5.ComputeHash(originalBytes);
            return System.Text.RegularExpressions.Regex.Replace(BitConverter.ToString(encodedBytes), "-", "").ToLower();
        }

You need something like this in the textBox:
введённое число - полученный хэш
введённое число - полученный хэш
введённое число - полученный хэш
...

But it is entered like this: (I entered 123)
123 - 411598a4370c524b67fce41973bdd401123 - 
411598a4370c524b67fce41973bdd401123 - 202cb962ac59075b964b07152d234b70

Why??? Is everything mixed
up in MB due to the fact that multiLine is installed in the textbox?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Moolz Rivers, 2019-10-28
@SaddledSharp

I'm stupid... :/
decided like this:
It was necessary to add "\r\n" to the beginning, because when debugging, I noticed that they are sorted not by \n, but also by the symbol \r, in general,
sorry for the spam, I honestly didn’t know, after the question I went to debug and decided right away :\ leave, MB someone will need

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question