简体   繁体   中英

What kind of encryption method is this?

I found out a method while looking at a code and it decrypts some encrypted text. I wonder what kind of encryption/decryption method is used for that. Any helps will be appreciated. Thanks.

public static string smethod_2(string stream_0, string stream_1)
        {
            string str = "";
            long num1 = checked((long)Math.Round(unchecked((double)Strings.Len(stream_0) / 2.0)));
            long num2 = 1;
            while (num2 <= num1)
            {
                int num3 = checked((int)Math.Round(Conversion.Val("&H" + Strings.Mid(stream_0, (int)(2L * num2 - 1L), 2))));
                int num4 = Strings.Asc(Strings.Mid(stream_1, checked((int)(unchecked(num2 % (long)Strings.Len(stream_1)) + 1L)), 1));
                str += Conversions.ToString(Strings.Chr(num3 ^ num4));
                checked { ++num2; }
            }
            return str;
        }

Here is the method.

smethod_2("0D5D343E203D207F6A4D2B483039333C680046522D48203832", smethod_2("68126600161113667168", "#KJKSZPJ#"));

And this is an example to show you how it is used.

It's a simple repeating-key XOR cipher . The function smethod_2() takes two arguments. The first is the plaintext, represented by a string of hex digits, and the second is the encryption/decryption key. (The algorithm is symmetrical, so encryption and decryption are both performed with the same function.) Essentially all it does is fetch corresponding bytes from both strings and XOR their values together to obtain an output ASCII value (repeating the characters of the key string as many times as needed to cover the entire plaintext)

For some reason, the first (2nd, 3rd, etc.) byte of the plaintext is XORed with the second (3rd, 4th, etc.) byte of the key. You should be able to satisfy yourself that the result of the inner nested call smethod_2("68126600161113667168", "#KJKSZPJ#") is '#X-SLAYER#' , which then becomes the key used to decipher the longer hex string.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM