下载此文档

基于c++des加密解密算法实现.doc


文档分类:IT计算机 | 页数:约13页 举报非法文档有奖
1/13
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/13 下载此文档
文档列表 文档介绍
页眉..::类的共有接口只设计一个,即加密解密函数,用一个bool参数区分是加密还是解密。其他像读文件,写文件,加密变换函数等等设置为私有涉及内容:文件操作,STL向量,数制变换,位操作及函数设计等等。代码:#include<fstream>#include<string>#include<iostream>#include<strstream>#include<vector>#include<>usingnamespacestd;/************************************************************************//************************************************************************//*DES类声明*/classDES{public:DES();/*构造函数*/voidencrypt(boolflag=true);/*加解密函数*/private:stringplaintextFilePath_;/*明文文件路径*/stringciphertextFilePath_;/*密文文件路径*/stringkeyFilename_;/*密钥文件路径*/stringplaintext_;/*明文存储*/stringciphertext_;/*密文存储*/stringkey_;/*密钥存储*/vector<vector<int>>subkey_;/*子密钥存储*/voidgetsubkey_();/*计算子密钥*/voidsetPlaintextFilePath_();/*设置明文路径*/voidsetCiphertextFilePath_();/*设置密文路径*/voidsetKeyFilePath_();/*设置密钥路径*/stringreadData_(stringfilename);/*读取文件*/voidsaveData_(stringfilename,stringdata);/*保存文件*/vector<int>string2bit_(stringstr);/*string类型转为ASCII二进制数*/stringbit2string_(vector<int>v);/*ASCII二进制数转为string类型*/页眉..页脚vector<int>int2bit_(vector<int>vecInt);/*整形数0-15化为二进制*/vector<int>vecXor_(vector<int>vL,vector<int>vR);/*向量异或*/vector<int>leftIterMove_(vector<int>movVec,intloopStep);/*数据左移loopStep位*/vector<int>vecReplace_(vector<int>v,constunsignedintvArray[]);/*向量数据按vArray中数据重排序*/vector<int>vecMerge_(vector<int>vL,vector<int>vR);/*合并两个向量*/vector<int>f_(vector<int>vecR,vector<int>vecKey);/*f函数*/vector<int>S_(vector<int>vecRKey);/*S盒函数*//************************************************************************//*变换矩阵*/onstunsignedintPC_1_[56];onstunsignedintPC_2_[48];onstunsignedintLOOP_[16];onstunsignedintIP_[64];onstunsignedintIPR_[64];onstunsignedintSBOX_[8][4][16];onstunsignedintE_[48];onstunsignedintP_[32];/************************************************************************/};,以备后面的代码调用。代码:#include""/************************************************************************//************************************************************************

基于c++des加密解密算法实现 来自淘豆网m.daumloan.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数13
  • 收藏数0 收藏
  • 顶次数0
  • 上传人sdnmy78
  • 文件大小0 KB
  • 时间2016-01-16