我发现自己陷入了绝望的境地,试图理解下面的算法。有人认出来吗?
它来自反编译的程序集。我正在编写一个PHP网站前端应用程序,需要使用这段可怕代码生成的密码作为登录凭据。
public static void Crypt(string ThisCle, string Buffer, long BufferLength)
{
int index = 1;
do
{
WUC.cry[index] = char.MinValue;
checked { ++index; }
}
while (index <= 32000);
WUC.cle = Conversions.ToCharArrayRankOne(ThisCle);
WUC.si = 0;
WUC.x1a2 = 0;
WUC.i = 0;
WUC.j = 0;
WUC.l = 0;
while ((long) WUC.j <= checked (BufferLength - 1L))
{
byte num1 = checked ((byte) Strings.Asc(Strings.Mid(Buffer, WUC.j + 1, 1)));
WUC.Assemble();
WUC.cfc = WUC.inter >> 8;
WUC.cfd = WUC.inter & (int) byte.MaxValue;
WUC.compte = 0;
do
{
WUC.cle[WUC.compte] = Strings.Chr(Strings.Asc(WUC.cle[WUC.compte]) ^ (int) num1);
checked { ++WUC.compte; }
}
while (WUC.compte <= 15);
byte num2 = checked ((byte) ((int) num1 ^ (WUC.cfc ^ WUC.cfd)));
byte num3 = (byte) ((uint) num2 >> 4);
byte num4 = checked ((byte) ((int) num2 & 15));
char ch;
switch (num3)
{
case (byte) 0:
ch = 'a';
break;
case (byte) 1:
ch = 'b';
break;
case (byte) 2:
ch = 'c';
break;
case (byte) 3:
ch = 'd';
break;
case (byte) 4:
ch = 'e';
break;
case (byte) 5:
ch = 'f';
break;
case (byte) 6:
ch = 'g';
break;
case (byte) 7:
ch = 'h';
break;
case (byte) 8:
ch = 'i';
break;
case (byte) 9:
ch = 'j';
break;
case (byte) 10:
ch = 'k';
break;
case (byte) 11:
ch = 'l';
break;
case (byte) 12:
ch = 'm';
break;
case (byte) 13:
ch = 'n';
break;
case (byte) 14:
ch = 'o';
break;
case (byte) 15:
ch = 'p';
break;
}
WUC.cry[checked (WUC.j * 2)] = ch;
switch (num4)
{
case (byte) 0:
ch = 'a';
break;
case (byte) 1:
ch = 'b';
break;
case (byte) 2:
ch = 'c';
break;
case (byte) 3:
ch = 'd';
break;
case (byte) 4:
ch = 'e';
break;
case (byte) 5:
ch = 'f';
break;
case (byte) 6:
ch = 'g';
break;
case (byte) 7:
ch = 'h';
break;
case (byte) 8:
ch = 'i';
break;
case (byte) 9:
ch = 'j';
break;
case (byte) 10:
ch = 'k';
break;
case (byte) 11:
ch = 'l';
break;
case (byte) 12:
ch = 'm';
break;
case (byte) 13:
ch = 'n';
break;
case (byte) 14:
ch = 'o';
break;
case (byte) 15:
ch = 'p';
break;
}
WUC.cry[checked (WUC.j * 2 + 1)] = ch;
checked { ++WUC.j; }
}
}
有一种“Decrpyt”方法以类似的方式工作。密码长度为16个字符。
答案 0 :(得分:5)
这看起来可能是原始(Delphi)来源:
http://files.codes-sources.com/fichier_fullscreen.aspx?id=45245&f=pc1.pas&lang=en
这是一个PC1密码,对于其他语言的某些实现,请查看here。