I'm trying to XOR each letter from my TextBox with each value from my array.
The problem is, that when I convert double to int array, my int array result stores only one value.
If I run my code I get first letter XORed, but if I input more then one, I get message :
System.IndexOutOfRangeException: Index was outside the bounds of the array.
I have tried myself to create an int array like: int[] result = new int[] {1,2,3,4,5,6,7}; and I didn't have any problems with XORing up to 7 letters..
private void iTalk_Button_12_Click(object sender, EventArgs e)
{
ambiance_RichTextBox1.Text = XorText(ambiance_RichTextBox1.Text);
}
private string XorText(string text)
{
string newText = "";
double r = 3.9;
double[] first_value = new double[text.Length];
double[] to_int_array = new double[text.Length];
for (int i = 0; i < text.Length; i++)
{
double get_first = r * i * (1 - i);
int index = (int)(i * text.Length);
first_value[index] = get_first;
}
for (int i = 0; i < text.Length; i++)
{
int xnbb = 0;
if (first_value[i] > Math.Exp(Math.Log(2) * (-i)))
{
double get_first = first_value[i] - Math.Exp(Math.Log(2) * (-i));
xnbb = 1;
}
double array_of_values = xnbb + 1 * Math.Round(Math.Exp(Math.Log(2) * (24 - i)));
int index = (int)(i * text.Length);
to_int_array[index] = array_of_values;
int[] result = new int[] { Convert.ToInt32(to_int_array[i]) };
int charValue = Convert.ToInt32(text[i]);
charValue ^= result[i]%320;
newText += char.ConvertFromUtf32(charValue);
}
return newText;
}
return newText;can stay.