. Net/C # implementation: encryption and decryption algorithm for the website password in the FlashFXP address book

Source: Internet
Author: User

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 ();
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.