我正在编写一个程序,它将字符串“123124125”转换为长度为 3 的整数数组,如下所示:
int[0] = 123
int[1] = 124
int[2] = 125
假设密文字符串有123124125。
我用了:
int number[100];
int length1 = ciphertext-> Length;
int count = 0;
int count1 = 0;
char w[100];
while (count1 < length1)
{
number[count] = (ciphertext[count1] * 100) + (ciphertext[count1 + 1] * 10) + ciphertext[count1 + 2];
count++;
count1 = count1 + 3;
}
然后我希望使用这个公式来解密它并直接转换为字符串:
for (int i = 0; i < sizeof(number); i++)
{
String ^ demessage += Convert::ToChar(number[i] ^ (int(key) * 2 + int(key) / int(key)) % 255);
}
但它显示以下结果:
5553195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195195-....................................1849664615
我哪里错了?我是否需要先将 int 转换为 char 然后继续使用公式?
谢谢。非常感谢您的帮助。