- 1、本文档共5页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
Column permutation cipher 的编程实现
现代密码学与加解密技术实验报告
实验名称 Column permutation cipher 的编程实现 班 级 学 号 姓 名 日 期 成 绩 评 阅 人
软件学院实验环境列置换的加密原理是,明文按行填写在一个矩阵中,而密文则是以预订的顺序按列读取生成的。如果矩阵是4行5列,那么短语“ENCRYPTION ALGORITHMS”可以如下写入该矩阵中
按一定的顺序读取生成密文对于这个例子如果读取顺序是4 1 2 3那么密文就是“RILIS EYOGT NPNOH CTARM”这种方法要求填满矩阵,因此字母不够的时候就得填充X或Q等无效字符
实验用程序清单
#include stdafx.h
#includestring.h
#define max 100
void jiami(char plantext[max],char key[max],char cipher[max],char plantext2[max])
{
int i,m,k,l,ml,mk;
char copy[max];
l=strlen(key);
k=strlen(plantext);
int b[max];
for(i=0;il;i++)//复制key数组
{
copy[i]=key[i];
}
for(i=0;il;i++)
{
printf(%c,copy[i]);
}
printf(\n);
for(i=0;il;i++)//对关键词数组进行升序排序
{
int j;
char temp;
for(j=0;jl-i-1;j++)
{
if(copy[j]copy[j+1])
{
temp=copy[j];
copy[j]=copy[j+1];
copy[j+1]=temp;
}
}
}
for(i=0;il;i++)
{
printf(%c,copy[i]);
}
printf(\n);
for(i=0;il;i++)//获取读取序列,序列存储在b[l]中
{
int j;
int index=0;
for(j=0;jl;j++)
{
if(copy[i]==key[j])
index=j;
}
b[i]=index;
}
for(i=0;il;i++)
{
printf(%d,b[i]);
}
printf(\n);
i=0;
for(m=k%l;ml;m++)//在明文最后补q
{
plantext[k+i]=q;
i++;
}
ml=k+i;
mk=ml;
for(i=0;iml;i++)
{
printf(%c,plantext[i]);
}
printf(\n);
m=(k+l-1)/l;
printf(%d\n,m);
ml=0;
for(i=0;il;i++)//填充密文数组
{
int j;
for(j=0;jm;j++)
{
cipher[ml]=plantext[j*l+b[i]];//cipher的前m个数对应明文矩阵的b[i]列
ml++;
}
}
printf(%d\n,ml);
printf(密文为:);
for(i=0;iml;i++)//输出密文
{
printf(%c,cipher[i]);
}
printf(\n);
ml=0;
for(i=0;il;i++)//填充解密数组
{
int j;
for(j=0;jm;j++)
{
plantext2[j*l+b[i]]=cipher[ml];//cipher的前m个数对应明文矩阵的b[i]列
ml++;
}
}
printf(原文为:);
for(i=0;iml;i++)//输出原文
{
printf(%c,plantext2[i]);
}
printf(\n);
}
int _tmain(int argc, _TCHAR* argv[])
{
char plantext1[max],plantext2[max],cipher[max],key[max];
printf(请输入明文\n);
scanf(%s,plantext1);
printf(请输入关键词\n);
scanf(%s,key);
jiami(plantext1,key,cipher,plantext2);
return 0;
}
思考题
Column permutation cipher 的原理是什么
您可能关注的文档
- Bounded Search and Symbolic Inference for Constraint Optimization.pdf
- Boussinesq方程的精确解及其应用.pdf
- Brain Dynamics across levels of Organization..pdf
- BPEL整合WEB服务的一个完整案例.doc
- BP网络激励函数的研究.pdf
- Brazil Cooperative Development of a Software Industry.pdf
- Breakdown of Fermi Liquid Theory in Doped Mott Insulators by Dynamical Spectral Weight Tran.pdf
- Brief Analysis on Classification of the Hyperbole.doc
- Brownian Dynamics Simulations of SingleFile Motion Through Nanochannels.pdf
- Brpxtln考研英语作文模板库.doc
- Colour Difference Evaluation.doc
- Combined Effect of QCD Resummation and QED Radiative Correction to W boson Observables at t.pdf
- COMCORBA互操作的研究与实现.pdf
- Comment on Bayesian Analysis of Pentaquark Signals from CLAS Data, with Response to the Rep.pdf
- Comment on ``Analysis of chaotic motion and its shape dependence in a generalized piecewise.pdf
- Combat Search rapidly for highly similar proteincoding sequences using bipartite graph mat.pdf
- Comments on Analytic and Numerical Study of Preheating Dynamics.pdf
- Comments on Perspectives on Galactic Dynamics via General Relativity.pdf
- Common Proper Motion Search for Faint Companions Around EarlyType Field Stars Progress R.pdf
- Common ordinary usual normal的区别.ppt
文档评论(0)