namespace JiaMiSuanFa
{
// Token: 0x02000019 RID: 25
public class SimpleProtectstring
{
// Token: 0x0600005E RID: 94 RVA: 0x00004608 File Offset: 0x00002808
public static string Encrypt(string data, string pass)
{
if (!string.IsNullOrEmpty(data) && !string.IsNullOrEmpty(pass))
{
byte[] bytes = SimpleProtectstring.encoding_0.GetBytes(data);
byte[] array = SimpleProtectstring.encoding_0.GetBytes(pass);
array = SimpleProtectstring.smethod_3(array, 256);
return SimpleProtectstring.smethod_2(SimpleProtectstring.smethod_0(bytes, array));
}
return string.Empty;
}
// Token: 0x0600005F RID: 95 RVA: 0x0000465C File Offset: 0x0000285C
public static string Decrypt(string data, string pass)
{
string text = string.Empty;
if (!string.IsNullOrEmpty(data) && !string.IsNullOrEmpty(pass))
{
try
{
byte[] array = SimpleProtectstring.smethod_1(data);
byte[] array2 = SimpleProtectstring.encoding_0.GetBytes(pass);
array2 = SimpleProtectstring.smethod_3(array2, 256);
byte[] array3 = SimpleProtectstring.smethod_0(array, array2);
text = ((array3.Length != 0) ? SimpleProtectstring.encoding_0.GetString(array3) : "");
}
catch (Exception)
{
text = string.Empty;
}
return text;
}
return text;
}
// Token: 0x06000060 RID: 96 RVA: 0x000046DC File Offset: 0x000028DC
private static byte[] smethod_0(byte[] byte_0, byte[] byte_1)
{
if (byte_0 != null && byte_1 != null)
{
int num = 0;
int num2 = 0;
byte[] array = new byte[byte_0.Length];
for (int i = 0; i < byte_0.Length; i++)
{
num = (num + 1) % byte_1.Length;
num2 = (num2 + (int)byte_1[num]) % byte_1.Length;
byte b = byte_1[num];
byte_1[num] = byte_1[num2];
byte_1[num2] = b;
byte b2 = byte_0[i];
byte b3 = byte_1[(int)(byte_1[num] + byte_1[num2]) % byte_1.Length];
array[i] = b2 ^ b3;
}
return array;
}
return null;
}
// Token: 0x06000061 RID: 97 RVA: 0x0000474C File Offset: 0x0000294C
private static byte[] smethod_1(string string_0)
{
int length = string_0.Length;
if (length > 0 && length % 2 == 0)
{
int num = length / 2;
byte[] array = new byte[num];
for (int i = 0; i < num; i++)
{
char c = string_0[i * 2];
int num2 = (int)(c - ((c >= 'A') ? '7' : '0'));
if (num2 >= 16)
{
return null;
}
char c2 = string_0[i * 2 + 1];
int num3 = (int)(c2 - ((c2 >= 'A') ? '7' : '0'));
if (num3 >= 16)
{
return null;
}
array[i] = (byte)(num2 * 16 + num3);
}
return array;
}
return null;
}
// Token: 0x06000062 RID: 98 RVA: 0x000047D4 File Offset: 0x000029D4
private static string smethod_2(byte[] byte_0)
{
if (byte_0 != null && byte_0.Length >= 1)
{
StringBuilder stringBuilder = new StringBuilder(byte_0.Length * 2);
foreach (int num in byte_0)
{
if (num < 0)
{
return null;
}
int num2 = num / 16;
stringBuilder.Append((char)(num2 + ((num2 > 9) ? 55 : 48)));
num2 = num % 16;
stringBuilder.Append((char)(num2 + ((num2 > 9) ? 55 : 48)));
}
return stringBuilder.ToString();
}
return null;
}
// Token: 0x06000063 RID: 99 RVA: 0x0000484C File Offset: 0x00002A4C
private static byte[] smethod_3(byte[] byte_0, int int_0 = 256)
{
byte[] array = new byte[int_0];
for (int i = 0; i < int_0; i++)
{
array[i] = (byte)i;
}
int num = 0;
for (int j = 0; j < int_0; j++)
{
num = (num + (int)array[j] + (int)byte_0[j % byte_0.Length]) % int_0;
byte b = array[j];
array[j] = array[num];
array[num] = b;
}
return array;
}
// Token: 0x04000046 RID: 70
private static Encoding encoding_0 = Encoding.UTF8;
}
}
|