Refer to CCFer & TLFer: kanbol's Java code translation and modification:
Kanbol said: Previously, I wrote a program in TLF to automatically update the flashfxp address book, that is, to modify the sites. dat file.
Now we have posted the encryption and decryption algorithm of flashfxp. By the way, the structure of the sites. dat file
The following code is visible to the algorithm,
The structure of the sites. dat file is relatively simple. If you open it directly using ultraedit, you can see a text file.
Switch to the hexadecimal editing mode to see a little different.
A site name, including its directory names in a "[]", for example, the site sitename under the subdirectory def under the directory abc
// C # Code:
// Using System;
// Using System. Text;
Public class Class1
{
Private static char [] key = "yA36zA48dEhfrvghGRg57h5UlDv3". ToCharArray ();
Public static void Main ()
{
System. Console. Out. WriteLine (Decode (Encode ("password ")));
System. Console. Out. WriteLine (Decode (Encode ("Microshaoft ")));
System. Console. Out. WriteLine (Decode (Encode ("FlashFXP ")));
System. Console. Out. WriteLine (Decode (Encode ("flashFXP ")));
}
Public static string Decode (string x)
{
System. Text. StringBuilder sb = new System. Text. StringBuilder ();
Char [] ca = x. ToCharArray ();
For (int I = 0; I <(ca. Length-2); I ++ = 2)
{
String s1 = "" + ca [I + 2] + ca [I + 3];
String s2 = "" + System. Convert. ToString (byte) key [(I/2) % 13], 16 );
String s3 = "" + ca [I] + ca [I + 1];
Int m = (System. Convert. ToInt32 (s1, 16) ^ System. Convert. ToInt32 (s2, 16)-System. Convert. ToInt32 (s3, 16 );
If (m <0)
{
MB + = 255;
}
Sb. Append (char) (short) m ));
}
Return sb. ToString ();
}
Public static string Encode (string x)
{
Char [] ca = x. ToCharArray ();
Int k = new System. Random (). Next (255 );
System. Text. StringBuilder sb = null;
If (k> 15)
{
Sb = new System. Text. StringBuilder ("" + System. Convert. ToString (k, 16 ));
}
Else
{
Sb = new System. Text. StringBuilder ("0" + System. Convert. ToString (k, 16 ));
}
Int m = System. Convert. ToInt32 (sb. ToString (), 16 );
For (int I = 0; I <ca. Length; I ++)
{
If (ca [I] + m)> 255)
{
M = (ca [I] + m)-255) ^ key [I % 13];
}
Else
{
M = (ca [I] + m) ^ key [I % 13];
}
If (m> 15)
{
Sb. Append (System. Convert. ToString (m, 16 ));
}
Else
{
Sb. Append ("0" + System. Convert. ToString (m, 16 ));
}
}
Return sb. ToString (). ToUpper ();
}
}