中国地质大学信息安全实习.docx
- 文档编号:5482067
- 上传时间:2022-12-16
- 格式:DOCX
- 页数:31
- 大小:331.11KB
中国地质大学信息安全实习.docx
《中国地质大学信息安全实习.docx》由会员分享,可在线阅读,更多相关《中国地质大学信息安全实习.docx(31页珍藏版)》请在冰豆网上搜索。
中国地质大学信息安全实习
中国地质大学(武汉)计算机学院
信息安全实习报告
姓名:
保密
班级:
192082
指导老师:
任伟
时间:
2010年12月18日
为学弟学妹做贡献咯
均调试通过
1.使用VC++编程语言设计实现一个200位以上十进制数运算的程序库:
能够完成大整数加、减、乘、除、求模、与、或、非、异或等运算。
2.程序都运行通过了,但是粘到word上后会有字符的转换,再粘到vc中时会有字符类型的错误,可以在复制时先删除word中的图片就可避免
3.
小提示
嗨,此程序纯属坑爹,不信你可以看每个图片左上角的程序名都叫做坑爹!
程序还是要自己写啊,呵呵,还是积分好啊!
哈哈哈哈哈哈哈哈,如有雷同,你丫就是傻B,下那么多坑爹的作品
运行截图
#include
#include
usingnamespacestd;
classBigFigure{
stringnum1,num2;
stringoutcome;
intprecision;
charoperation;
public:
BigFigure(){
num1=num2="0";
outcome="0";
precision=5;
}
string&plus(string&,string&);
string&sutration(string&,string&);
string&multplication(string&,string&);
string&division(string&,string&);
voidshow();
voidBigFigueInterface();
string&revese(string&);
friendistream&operator>>(istream&i,BigFigure&a){
returni>>a.um1>>a.operation>>a.num2;
}
~BigFigure(){}
};
voidBigFigue:
:
show()
{
cout<<"结果是:
"< } voidBigFigure: : BigFigureInterface() { BigFiurea; cout<<"**************************************************************************"< cout<<"大数的运算"< cout<<"**************************************************************************"< cout<<"注意事项: "< cout<<"1.输入形式为: A[空格或换行]O[空格或换行]B。 "< cout< cout<<"2.1中A、B为大数,O为运算符(如输入: 123456789/432432)。 "< cout< cout<<"3.既然处理大数,就没必要输入小数点位了。 "< cout< cout<<"4.加减不能处理负号,乘除可以。 "< cout<<"5.异或,非。 。 。 。 。 。 。 "< cout< cout<<"请按照上述规则输入: "< cin>>a; while(a.operation! ='0'){ switch(a.opation){ case'+'a.pus(anum1,anum2); a.show();break; case'-': a.subtration(a.num1,a.num2); a.show();break; case'*': a.multiplication(a.num1,a.num2); a.show();break; case'/': a.division(a.num1,a.num2); a.show();break; default: cout< )"< } cout< cout<<"请按照上述规则输入你要计算的下一组数据: "< ci>>a; } syste("cl); //system("pause"); } string&BigFiure: revese(string&s){ charc; intt=s.size(); for(inti=0;i cs[i]; s[i]=s[t-i-1]; s[t-i-1]=c; } returns; } string&BgFigure: plus(string&str1,string&str2){//加法运算,未处理符号 intin=0,i,t=0; strintemp; str1=revese(str1); str2=revese(str2); min=str1.size() str1.size(): str2.size(); for(i=0;i temp+=(str1[i]+str2[i]-96+t)%10+48; t=(str1[i]+str2[i]-96+t)/10; } if(min==str1.size()){ while(i temp+=(str2[i]+t-48)%10+48; t=(str2[i]-48+t)/10; i++; } if(t)temp+='1'; } else{ while(i temp+=(str1[i]+t-48)%10+48; t=(str1[i]-48+t)/10; i++; } if(t)temp+='1'; } outcome=revese(temp); returnoutcome; } string&BigFigure: : subtration(string&str1,string&str2) {//减法运算,未处理符号 intmin=0,flag,i,t=0; stringtemp; if(str1.size()>str2.size()||(str1.size()==str2.size()&&pare(str2)==1)){ str1=revese(str1); str2=revese(str2); flag=0; min=str2.size(); } elseif(str1.size()==str2.size()){ if(! pare(str2)){ outcome='0'; returnoutcome; } if(pare(str2)==-1){ temp=str1; str1=revese(str2); str2=revese(temp); flag=1; min=str2.size(); } } else{ temp=str1; str1=revese(str2); str2=revese(temp); flag=1; min=str2.size(); } for(i=0;i if(str1[i]-t temp+=str1[i]+10-t-str2[i]+48; t=1; } else{ temp+=str1[i]-t-str2[i]+48; t=0; } } while(i if(! t){ while(i temp+=str1[i]; i++; } break; } if(str1[i]! ='0'){temp+=str1[i]-t;t=0;} elsetemp+='9'; i++; } strings; for(unsignedintk=temp.size()-1;k>=0;k--){ if(temp[k]! ='0'){ for(intn=k;n>=0;n--) s+=temp[n]; break; } } if(flag)s='-'+s; outcome=s; returnoutcome; } string&BigFigure: : multiplication(string&str1,string&str2){//乘法运算,已处理符号 charc='0',flag=0; stringtemp1,temp2="0"; if(str1[0]=='0'||str2[0]=='0'){ outcome="0"; returnoutcome; } if(str1[0]=='-'){flag++;str1.erase(0,1);} if(str2[0]=='-'){flag++;str2.erase(0,1);} str1=revese(str1); str2=revese(str2); for(unsignedinti=0;i c='0'; for(unsignedintj=0;j temp1+=((str2[i]-48)*(str1[j]-48)+c-48)%10+48; c=((str2[i]-48)*(str1[j]-48)+c-48)/10+48; } if(c! ='0')temp1+=c; temp1=revese(temp1); for(intk=0;k temp1+='0'; temp2=plus(temp1,temp2); } if(flag%2)temp2='-'+temp2; outcome=temp2; returnoutcome; } string&BigFigure: : division(string&str1,string&str2){//除法运算,已处理符号 intstr=0,flag=0,flag1=0,flag2=0; stringtemp,temps,tempt; if(str2=="0"){ outcome="Inf"; returnoutcome; } if(str2=="1"||str1=="0"){ outcome=str1; returnoutcome; } if(str1[0]=='-'){flag++;str1.erase(0,1);} if(str2[0]=='-'){flag++;str2.erase(0,1);} for(inti=0;i str=0; temp+=str1[i]; if(temp[0]=='0')temp.erase(0,1); if(temp.size()>str2.size()|| (temp.size()==str2.size()&&pare(str2)>=0)){ while(temp.size()>str2.size()|| (temp.size()==str2.size()&&pare(str2)>=0)){ tempt=str2; temp=subtration(temp,tempt); str++; } temps+=str+48; } elseif(temp.size()==str2.size()&&pare(str2)==0)temps+='1'; elsetemps+='0'; } flag1=temps.size(); if(temp! ="0"&&precision)temps+='.'; for(i=0;i<=precision&&temp! ="0";i++){//小数后位的处理 str=0; temp+='0'; if(temp.size()>str2.size()|| (temp.size()==str2.size()&&pare(str2)>=0)){ while(temp.size()>str2.size()|| (temp.size()==str2.size()&&pare(str2)>=0)){ tempt=str2; temp=subtration(temp,tempt); str++; } temps+=str+48; } elseif(temp.size()==str2.size()&&pare(str2)==0)temps+='1'; elsetemps+='0'; } flag2=temps.size()-2; if(temps[temps.size()-1]>='5'&&flag2-flag1==precision){//四舍五入处理 temps.erase(flag1,1); temps.erase(temps.size()-1,1); temp="1"; temps=plus(temps,temp); if(temps.size()>flag2)temps.insert(flag1+1,1,'.'); elsetemps.insert(flag1,1,'.'); } elseif(flag2-flag1==precision)temps.erase(temps.size()-1,1); for(unsignedintk=0;k if(temps[k]! ='0'||temps[k+1]=='.'){ for(intn=k;n temp+=temps[n]; break; } } if(flag%2)temp='-'+temp; outcome=temp; returnoutcome; } intmain(){//主函数 BigFigurea; a.BigFigureInterface(); return0; } s.huH^,bB! V 使用VC++编程语言编写一个程序,实现DES算法,包括以下环节,密钥通过随机函数产生,并应用密文反馈(CFB)工作模式和输出反馈(OFB)工作模式进行加密、解密和输出。 截图 #include"stdio.h" #include"math.h" #include"stdax.h" staticvoidscrunch(unsignedchar*,unsignedlong*); staticvoidunscrun(unsignedlong*,unsignedchar*); staticvoiddesfunc(unsignedlong*,unsignedlong*); staticvoidcookey(unsignedlong*); staticunsignedlongKnL[32]={0L}; staticunsignedlongKnR[32]={0L}; staticunsignedlongKn3[32]={0L}; staticunsignedcharDf_Key[24]={ 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef, 0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10, 0x89,0xab,0xcd,0xef,0x01,0x23,0x45,0x67}; staticunsignedshortbytebit[8]={ 0200,0100,040,020,010,04,02,01}; staticunsignedlongbigbyte[24]={ 0x800000L,0x400000L,0x200000L,0x100000L, 0x80000L,0x40000L,0x20000L,0x10000L, 0x8000L,0x4000L,0x2000L,0x1000L, 0x800L,0x400L,0x200L,0x100L, 0x80L,0x40L,0x20L,0x10L, 0x8L,0x4L,0x2L,0x1L}; /*UsethekeyschedulespecifiedintheStandard(ANSIX3.92-1981).*/ staticunsignedcharpc1[56]={ 56,48,40,32,24,16,8,0,57,49,41,33,25,17, 9,1,58,50,42,34,26,18,10,2,59,51,43,35, 62,54,46,38,30,22,14,6,61,53,45,37,29,21, 13,5,60,52,44,36,28,20,12,4,27,19,11,3}; staticunsignedchartotrot[16]={ 1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28}; staticunsignedcharpc2[48]={ 13,16,10,23,0,4,2,27,14,5,20,9, 22,18,11,3,25,7,15,6,26,19,12,1, 40,51,30,36,46,54,29,39,50,44,32,47, 43,48,38,55,33,52,45,41,49,35,28,31}; voiddeskey(key,edf)/*ThankstoJamesGillogly&PhilKarn! */ unsignedchar*key; shortedf; { registerinti,j,l,m,n; unsignedcharpc1m[56],pcr[56]; unsignedlongkn[32]; for(j=0;j<56;j++){ l=pc1[j]; m=l&07; pc1m[j]=(key[l>>3]&bytebit[m])? 1: 0; } for(i=0;i<16;i++){ if(edf==DE1)m=(15-i)<<1; elsem=i<<1; n=m+1; kn[m]=kn[n]=0L; for(j=0;j<28;j++){ l=j+totrot[i]; if(l<28)pcr[j]=pc1m[l]; elsepcr[j]=pc1m[l-28]; } for(j=28;j<56;j++){ l=j+totrot[i]; if(l<56)pcr[j]=pc1m[l]; elsepcr[j]=pc1m[l-28]; } for(j=0;j<24;j++){ if(pcr[pc2[j]])kn[m]|=bigbyte[j]; if(pcr[pc2[j+24]])kn[n]|=bigbyte[j]; } } cookey(kn); return; } staticvoidcookey(raw1) registerunsignedlong*raw1; { registerunsignedlong*cook,*raw0; unsignedlongdough[32]; registerinti; cook=dough; for(i=0;i<16;i++,raw1++){ raw0=raw1++; *cook=(*raw0&0x00fc0000L)<<6; *cook|=(*raw0&0x00000fc0L)<<10; *cook|=(*raw1&0x00fc0000L)>>10; *cook++|=(*raw1&0x00000fc0L)>>6; *cook=(*raw0&0x0003f000L)<<12; *cook|=(*raw0&0x0000003fL)<<16; *cook|=(*raw1&0x0003f000L)>>4; *cook++|=(*raw1&0x0000003fL); } usekey(dough); return; } voidcpkey(into) reg
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 中国地质大学 信息 安全 实习
![提示](https://static.bdocx.com/images/bang_tan.gif)