Exemplo n.º 1
0
 /// <summary>
 /// 带编码模式的字符串解密
 /// </summary>
 /// <param name="data">要解密的数据</param>
 /// <param name="pass">密码</param>
 /// <param name="em">编码模式</param>
 /// <returns>明文</returns>
 public String Decrypt(String data, String pass, NLCryptoBase.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)));
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 带编码模式的字符串加密
 /// </summary>
 /// <param name="data">要加密的数据</param>
 /// <param name="pass">密码</param>
 /// <param name="em">编码模式</param>
 /// <returns>加密后经过编码的字符串</returns>
 public String Encrypt(String data, String pass, NLCryptoBase.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)));
     }
 }