A
A
Anton_repr2019-04-15 10:57:56
C++ / C#
Anton_repr, 2019-04-15 10:57:56

How to remove elements of a string?

I'm making an encoder and ran into a problem. The essence of encryption is as follows: I enter the key and text, the text and the key are converted to binary form. The elements of the key are then written to the text through a character. I implemented it like this:

static char GetNextChar(string encrypt, ref int lastIndex)
        {
            if (++lastIndex >= encrypt.Length)
                lastIndex = 0;

            return encrypt[lastIndex];
        }

        public static string PairConcat(string Encrypt, string bina)
        {
            StringBuilder result = new StringBuilder();
            int index = -1;
            for (int i = 0; i < bina.Length; i++)
            {
                result.Append(bina[i]);
                result.Append(GetNextChar(Encrypt, ref index));
            }
                return result.ToString();                       
        }

After that, I translate from binary to string and get an encrypted string. The problem is decryption. I convert the string back to binary and get 1, yes 0. Now from this set of numbers, you need to remove the key elements represented in binary. Unfortunately, I have no idea how to do this. Help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2019-04-15
@zagayevskiy

OMG. Dude, damn it, learn the basics of the language already.
What you write for a warm-up is understandable, but it's stupid security through obscurity in its purest form. Do something useful (write a conversion to Base64 and vice versa, for example).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question