I am using CTR mode (it is a cipher in itself) in this code. I just wanted to see what you thought about it before I finish it.
(Yes, I know that the plaintext length and key length must be highly specific. I will take care of that with padding later.)
I just wanted to know if you thought if this code was cryptographically secure and if I could speed it up a little.
class Encrypt
{
public string CTR(string p, string key)
{
StringBuilder sb = new StringBuilder();
for (uint c = 0; c < (p.Length / key.Length); c++ )
{
char[] kc = key.ToCharArray();
char[] E = new char[key.Length];
char[] cc = c.ToString().ToCharArray();
int inc = 0;
foreach (char ch in kc)
{
E[inc] = (char)(ch ^ cc[0]); // Something goes wrong here when there are 2 digits in uint c. (CodeReview plz help)
inc++;
}
char[] pc = p.ToCharArray();
for (int i = 0; i < E.Length; i++)
{
sb.Append((char)(pc[i] ^ E[i]));
}
}
return sb.ToString();
}
}