private static byte[] EncryptEx(byte[] data, string pass) { byte[] result; if (data == null || pass == null) { result = null; } else { byte[] array = new byte[data.Length]; long num = 0L; long num2 = 0L; byte[] key = RC4Encrypt.GetKey(RC4Encrypt.Encode.GetBytes(pass), 256); for (long num3 = 0L; num3 < (long)data.Length; num3 += 1L) { num = (num + 1L) % (long)key.Length; num2 = (num2 + (long)((ulong)key[(int)checked ((System.IntPtr)num)])) % (long)key.Length; checked { byte b = key[(int)((System.IntPtr)num)]; key[(int)((System.IntPtr)num)] = key[(int)((System.IntPtr)num2)]; key[(int)((System.IntPtr)num2)] = b; byte b2 = data[(int)((System.IntPtr)num3)]; byte b3 = key[(int)unchecked (key[(int)checked ((System.IntPtr)num)] + key[(int)checked ((System.IntPtr)num2)]) % key.Length]; array[(int)((System.IntPtr)num3)] = (byte)checked (b2 ^ b3); } } result = array; } return(result); }
public static string Encrypt(string data, string pass, RC4Encrypt.EncoderMode em) { string result; if (data == null || pass == null) { result = null; } else { if (em == RC4Encrypt.EncoderMode.Base64Encoder) { result = System.Convert.ToBase64String(RC4Encrypt.EncryptEx(RC4Encrypt.Encode.GetBytes(data), pass)); } else { result = RC4Encrypt.ByteToHex(RC4Encrypt.EncryptEx(RC4Encrypt.Encode.GetBytes(data), pass)); } } return(result); }
public static string Decrypt(string data, string pass, RC4Encrypt.EncoderMode em) { string result; if (data == null || pass == null) { result = null; } else { if (em == RC4Encrypt.EncoderMode.Base64Encoder) { result = RC4Encrypt.Encode.GetString(RC4Encrypt.DecryptEx(System.Convert.FromBase64String(data), pass)); } else { result = RC4Encrypt.Encode.GetString(RC4Encrypt.DecryptEx(RC4Encrypt.HexToByte(data), pass)); } } return(result); }
public static string Decrypt(string data, string pass) { return(RC4Encrypt.Decrypt(data, pass, RC4Encrypt.EncoderMode.Base64Encoder)); }
private static byte[] DecryptEx(byte[] data, string pass) { return(RC4Encrypt.EncryptEx(data, pass)); }