Answer the question
In order to leave comments, you need to log in
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();
}
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question