Exemple #1
0
 /// <summary>
 /// 带编码模式的字符串加密
 /// </summary>
 /// <param name="data">要加密的数据</param>
 /// <param name="pass">密码</param>
 /// <param name="em">编码模式</param>
 /// <returns>加密后经过编码的字符串</returns>
 public static String Encrypt(String data, String pass, RC4Encrypt.EncoderMode em)
 {
     if (data == null || pass == null) return null;
     if (em == EncoderMode.Base64Encoder)
         return Convert.ToBase64String(EncryptEx(Encode.GetBytes(data), pass));
     else
         return ByteToHex(EncryptEx(Encode.GetBytes(data), pass));
 }
Exemple #2
0
 /// <summary>
 /// 带编码模式的字符串解密
 /// </summary>
 /// <param name="data">要解密的数据</param>
 /// <param name="pass">密码</param>
 /// <param name="em">编码模式</param>
 /// <returns>明文</returns>
 public static String Decrypt(String data, String pass, RC4Encrypt.EncoderMode em)
 {
     if (data == null || pass == null) return null;
     if (em == EncoderMode.Base64Encoder)
         return Encode.GetString(DecryptEx(Convert.FromBase64String(data), pass));
     else
         return Encode.GetString(DecryptEx(HexToByte(data), pass));
 }