/// <summary>
/// 解密/加密
/// </summary>
/// <param name="pText"> 明文 </param>
/// <param name="pPassword"> Keys </param>
/// <param name="pEnCryptTf"> true 加密: false 解密 </param>
/// <returns> 返回密文 </returns>
private static string EnOrDeCrypt(string pText, string pPassword, bool pEnCryptTf)
{
int MulNumber = pEnCryptTf ? 1 : -1;
int num;
int num4 = 0;
int num6 = 0;
int length = pPassword.Length;
//num6等于pPassword的每位asscii码相加
for (num = 0; num < length; num++)
{
num6 += pPassword[num];
}
//num6 等于 num6 除以 6 的整数
num6 /= 6;
int num3 = 0;
string str = "";
length = pText.Length;
for (num = 0; num < length; num++)
{
int num5 = pText[num];
num3++;
if (num3 == 6)
{
num3 = 0;
}
switch (num3)
{
case 0:
num4 = num5 - (MulNumber * (num6 - 2));
break;
case 1:
num4 = num5 + (MulNumber * (num6 - 5));
break;
case 2:
num4 = num5 - (MulNumber * (num6 - 4));
break;
case 3:
num4 = num5 + (MulNumber * (num6 - 2));
break;
case 4:
num4 = num5 - (MulNumber * (num6 - 3));
break;
case 5:
num4 = num5 + (MulNumber * (num6 - 5));
break;
}
if (num5 == 0)
{
throw Exection("EnOrDeCrypt中出现无法处理的字符");
}
int num7 = 1;
if (num4 > 0xffff)//0xffff=65535
{
num4 = num7 + ((num4 - 0xffff) - 1);
}
if (num4 < num7)
{
num4 = 0xffff - ((num7 - num4) - 1);
}
str = str + ((char) num4);
}
return str;
}
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!