/// <summary> /// 解压缩字符串 /// </summary> /// <param name="source"></param> /// <param name="key"></param> /// <returns></returns> public static string UnCryString(string source, string key) { string tmpStr = I3MD5.MD5String(key); byte[] keyBytes = Encoding.ASCII.GetBytes(tmpStr); //32*8 byte[] ivBytes = Encoding.ASCII.GetBytes(I3StringUtil.SubString(tmpStr, 0, 16)); //16*8 return(I3CryWeb.Decrypt(source, "Rijndael", keyBytes, ivBytes)); }
/// <summary> /// 加密流 /// </summary> /// <param name="source"></param> /// <param name="dest"></param> /// <param name="key"></param> /// <returns></returns> public static I3MsgInfo CryStream(Stream source, Stream dest, string key) { try { string tmpStr = I3MD5.MD5String(key); byte[] keyBytes = Encoding.ASCII.GetBytes(tmpStr); //32*8 byte[] ivBytes = Encoding.ASCII.GetBytes(I3StringUtil.SubString(tmpStr, 0, 16)); //16*8 SymmetricAlgorithm sym = SymmetricAlgorithm.Create("Rijndael"); sym.Key = keyBytes; sym.IV = ivBytes; I3CryWeb cry = new I3CryWeb(); cry.EncryptData(source, dest, sym, null, null, null); return(I3MsgInfo.Default); } catch (Exception ex) { return(new I3MsgInfo(false, ex.Message, ex)); } }