如题。看了半天MSDN也没明白,好象举的例都是字符串。

解决方案 »

  1.   

    你把第个BYTE都加1
    解密的时候再减1算是加密解密么
      

  2.   

    c=a xor ba=c xor b最简单的
      

  3.   

    RijndaelManaged(AES)算法是块式加密算法,
    对字符串加密也是转化到byte数组中,然后对byte数组进行加密。对文件加密的话,可以将文件读入到byte数组中,然后加密后
      

  4.   

    再贴段源码:
                RijndaelManaged aes = new RijndaelManaged();
                aes.GenerateKey();
                aes.GenerateIV();
                //加密
                FileStream fs = new FileStream("1.jpg",FileMode.Open,FileAccess.Read);
                byte[] contains = new byte[fs.Length];
                fs.Read(contains, 0, (int)fs.Length);
                MemoryStream ms = new MemoryStream();
                CryptoStream cts = new CryptoStream(ms,aes.CreateEncryptor(aes.Key,aes.IV), CryptoStreamMode.Write);
                cts.Write(contains, 0, (int)fs.Length);
                cts.FlushFinalBlock();
                cts.Close();
                byte[] encreptData = ms.ToArray();
                FileStream fs2 = new FileStream("e.jpg",FileMode.Create,FileAccess.Write);
                fs2.Write(encreptData, 0, encreptData.Length);
                fs2.Flush();
                fs2.Close();            //解密
                FileStream fs3 = new FileStream("e.jpg",FileMode.Open, FileAccess.Read);
                byte[] contains2 = new byte[fs3.Length];
                fs3.Read(contains2, 0, (int)fs3.Length);
                ms = new MemoryStream(contains2);
                cts = new CryptoStream(ms, aes.CreateDecryptor(aes.Key, aes.IV), CryptoStreamMode.Read);
                byte[] decryptData = new byte[fs3.Length];
                cts.Read(decryptData, 0, (int)fs3.Length);
                cts.Close();
                FileStream fs4 = new FileStream("d.jpg",FileMode.OpenOrCreate,FileAccess.Write);
                fs4.Write(decryptData, 0, decryptData.Length);
                fs4.Flush();
                fs3.Close();
                fs4.Close();