论文无忧网提供:计算机毕业论文范文|计算机毕业设计|计算机毕业论文
栏目导航 ASP Java Web .NET VB6.0 JAVA VC VF DELPHI PB 计算机网络 计算机科学与技术 PHP 安卓APP 其他 C# 代写论文
当前位置: > 计算机 > .NET >

DES加密解密系统研究与实现(VS2008)

目 录

                                    内容来自论文无忧网 www.paper51.com

前 言... 1 内容来自www.paper51.com

第1章 密码学概述... 2 copyright paper51.com

§1.1 对称密码模型... 2 copyright paper51.com

§1.2 密码编码学... 2

内容来自www.paper51.com

§1.3 公钥密码学... 3 内容来自论文无忧网 www.paper51.com

§1.3.1 公钥密码学概述... 3

内容来自www.paper51.com

§1.3.2 公钥密码学的应用... 4

http://www.paper51.com

第2章 DES加密算法... 4

内容来自论文无忧网 www.paper51.com

§2.1 DES算法发展与概述... 4 http://www.paper51.com

§2.2 DES算法原理... 6

paper51.com

§2.2.1 初始置换... 6 copyright paper51.com

§2.2.2 逆置换... 6 内容来自论文无忧网 www.paper51.com

§2.2.3 密钥处理... 6 内容来自www.paper51.com

§2.2.4 DES的迭代... 7 copyright paper51.com

第3章 程序实现... 8

http://www.paper51.com

§3.1 设计构想... 8 内容来自论文无忧网 www.paper51.com

§3.2 关键算法... 8 copyright paper51.com

§3.3 程序测试... 13 copyright paper51.com

§3.3.1 测试目的... 13

paper51.com

§3.3.2 测试过程... 13 内容来自www.paper51.com

§3.3.3 测试结果... 14 内容来自www.paper51.com

第4章 DES的安全性问题以及改进构想... 15

paper51.com

§4.1 DES存在的安全问题... 15

copyright paper51.com

§4.2 DES改进构想... 15

内容来自www.paper51.com

§4.2.1 改进构想提出背景... 15 paper51.com

§4.2.2 改进构想分析... 16 内容来自论文无忧网 www.paper51.com

结 论... 18 http://www.paper51.com

参考文献... 19 内容来自论文无忧网 www.paper51.com

paper51.com

§3.1  设计构想 paper51.com

本课题以C#为语言基础并结合密码学知识,对采用DES算法对文件进行加密和解密,有效地防止文件被恶意盗窃和篡改。

copyright paper51.com

程序界面如图3-1所示,用户选择要操作的文件,进行加密或解密操作。

内容来自论文无忧网 www.paper51.com

内容来自www.paper51.com

图3-1 软件界面

copyright paper51.com

§3.2 关键算法

http://www.paper51.com

  ///<summary> http://www.paper51.com

        ///DES加密算法

内容来自www.paper51.com

        ///</summary>

paper51.com

        ///<param name="inputFile">源文件路径</param> 内容来自www.paper51.com

        ///<param name="outFile">加密后文件路径</param> 内容来自论文无忧网 www.paper51.com

        ///<param name="pwd">加密密码</param> 内容来自论文无忧网 www.paper51.com

       public static void EncryptAlgorithm(string inputFile, string outFile,string pwd)

copyright paper51.com

        { 内容来自www.paper51.com

           using (FileStream fin = File.OpenRead(inputFile), paper51.com

               fout = File.OpenWrite(outFile)) paper51.com

           { 内容来自论文无忧网 www.paper51.com

               long lSize = fin.Length; // 输入文件长度

copyright paper51.com

               int size = (int)lSize;

paper51.com

               byte[] bytes = new byte[BUFFER_SIZE]; // 缓存 内容来自www.paper51.com

               int read = -1; // 输入文件读取数量

copyright paper51.com

               int value = 0; 内容来自论文无忧网 www.paper51.com

               // 获取IV和salt

内容来自论文无忧网 www.paper51.com

               byte[] IV = GenerateRandomBytes(16);

paper51.com

               byte[] salt = GenerateRandomBytes(16);

内容来自论文无忧网 www.paper51.com

               // 创建加密对象 copyright paper51.com

               SymmetricAlgorithm sma = DESAlgorithm.CreateRijndael(pwd, salt);

copyright paper51.com

               sma.IV = IV;

copyright paper51.com

               // 在输出文件开始部分写入IV和salt

paper51.com

               fout.Write(IV, 0, IV.Length);

copyright paper51.com

               fout.Write(salt, 0, salt.Length);

copyright paper51.com

               // 创建散列加密 http://www.paper51.com

               HashAlgorithm hasher = SHA256.Create(); http://www.paper51.com

               using (CryptoStream cout = new CryptoStream(fout, sma.CreateEncryptor(), 内容来自www.paper51.com

CryptoStreamMode.Write), 内容来自www.paper51.com

                   chash = new CryptoStream(Stream.Null, hasher, CryptoStreamMode.Write)) 内容来自www.paper51.com

               {

内容来自www.paper51.com

                   BinaryWriter bw = new BinaryWriter(cout);

内容来自www.paper51.com

                   bw.Write(lSize); copyright paper51.com

                   bw.Write(FC_TAG);

内容来自论文无忧网 www.paper51.com

                   // 读写字节块到加密流缓冲区

paper51.com

                   while ((read = fin.Read(bytes, 0, bytes.Length)) != 0)

copyright paper51.com

                   { 内容来自论文无忧网 www.paper51.com

                       cout.Write(bytes, 0, read);

内容来自论文无忧网 www.paper51.com

                       chash.Write(bytes, 0, read);

内容来自www.paper51.com

                       value += read; 内容来自www.paper51.com

                   }

内容来自www.paper51.com

                   // 关闭加密流 paper51.com

                   chash.Flush(); http://www.paper51.com

                   chash.Close(); copyright paper51.com

                   // 读取散列 内容来自www.paper51.com

                    byte[]hash = hasher.Hash; http://www.paper51.com

                   // 输入文件写入散列

内容来自论文无忧网 www.paper51.com

                   cout.Write(hash, 0, hash.Length);

paper51.com

                   // 关闭文件流

copyright paper51.com

                   cout.Flush(); 内容来自www.paper51.com

                   cout.Close(); 内容来自www.paper51.com

               } paper51.com

           } copyright paper51.com

        }

内容来自论文无忧网 www.paper51.com

        ///<summary>

paper51.com

        /// 解密文件 http://www.paper51.com

        ///</summary> 内容来自www.paper51.com

        ///<param name="inFile">待解密文件</param>

paper51.com

        ///<param name="outFile">解密后输出文件</param> http://www.paper51.com

        ///<param name="password">解密密码</param> 内容来自论文无忧网 www.paper51.com

       public static bool DecryptAlgorithm(string inFile, string outFile,string password) http://www.paper51.com

        { paper51.com

           // 创建打开文件流 内容来自论文无忧网 www.paper51.com

           using (FileStream fin = File.OpenRead(inFile), copyright paper51.com

               fout = File.OpenWrite(outFile)) 内容来自论文无忧网 www.paper51.com

           {

内容来自www.paper51.com

               int size = (int)fin.Length; paper51.com

                byte[]bytes = new byte[BUFFER_SIZE];

内容来自论文无忧网 www.paper51.com

               int read = -1; 内容来自论文无忧网 www.paper51.com

               int value = 0; copyright paper51.com

               int outValue = 0;

内容来自论文无忧网 www.paper51.com

               byte[] IV = new byte[16];

paper51.com

               fin.Read(IV, 0, 16);

内容来自www.paper51.com

               byte[] salt = new byte[16];

内容来自论文无忧网 www.paper51.com

               fin.Read(salt, 0, 16); 内容来自www.paper51.com

               SymmetricAlgorithm sma = DESAlgorithm.CreateRijndael(password, salt); copyright paper51.com

               sma.IV = IV;

copyright paper51.com

               value = 32; 内容来自论文无忧网 www.paper51.com

               long lSize = -1;

内容来自www.paper51.com

------分隔线----------------------------
联系方式