LIBCD.lib(wwincrt0.obj) : error LNK2001: unresolved external symbol _wWinMain@16

Yuixz 2013-11-09 09:33:31
// MyPuffin.cpp: implementation of the MyPuffin class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "MyPuffin.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

MyPuffin::MyPuffin()
{

}

MyPuffin::~MyPuffin()
{

}
void MyPuffin::encrypt(Byte *pt, Byte *e,Byte* ct)
{
int i,j;
Byte t1[64];
Byte t2[64];
memset(t1,0,64);
memset(t2,0,64);

//INIT P
for(i=0;i<64;i++)
t2[i]=pt[i];
//AK
for(j=0;j<64;j++)
t2[j]^=e[0*i+j];

for(j=0;j<64;j++)
t1[Px[j]-1]=t2[j];

for(i=0;i<32;i++)
{
//轮密钥异或
for(j=0;j<16;j++)
{
Byte b1=t1[4*j]*8+t1[4*j+1]*4+t1[4*j+2]*2+t1[4*j+3];
Byte b2[1];
b2[0]=Sbox[b1];
Byte b3[8];
T_8_1(b2,b3,1);
t2[4*j+0]=b3[4];
t2[4*j+1]=b3[5];
t2[4*j+2]=b3[6];
t2[4*j+3]=b3[7];
}
for(j=0;j<64;j++)
t2[j]^=e[64*(i+1)+j];

for(j=0;j<64;j++)
t1[Px[j]-1]=t2[j];
}
for(i=0;i<64;i++)
ct[i]=t1[i];
}
void MyPuffin::decrypt(Byte *ct, Byte *e,Byte* pt)
{
int i,j;
Byte t1[64];
Byte t2[64];
memset(t1,0,64);
memset(t2,0,64);

//INIT P
for(i=0;i<64;i++)
t2[i]=pt[i];
//AK
for(j=0;j<64;j++)
t2[j]^=e[(32-0)*64+j];

for(j=0;j<64;j++)
t1[Px[j]-1]=t2[j];

for(i=0;i<32;i++)
{
//轮密钥异或
for(j=0;j<16;j++)
{
Byte b1=t1[4*j]*8+t1[4*j+1]*4+t1[4*j+2]*2+t1[4*j+3];
Byte b2[1];
b2[0]=Sbox[b1];
Byte b3[8];
T_8_1(b2,b3,1);
t2[4*j+0]=b3[4];
t2[4*j+1]=b3[5];
t2[4*j+2]=b3[6];
t2[4*j+3]=b3[7];
}
for(j=0;j<64;j++)
t2[j]^=e[64*(32-i-1)+j];

for(j=0;j<64;j++)
t1[Px[j]-1]=t2[j];
}
for(i=0;i<64;i++)
ct[i]=t1[i];
}
void MyPuffin::R_Rounds(Byte *i,Byte *e, Byte *o)
{
Byte t1[64];
Byte t2[64];
for(int j=0;j<64;j++)
t1[j]=i[j]^e[j];
R_P(t1,t2);
R_S(t2,o);
}
void MyPuffin::R_P(Byte *i, Byte *o)
{
for(int j=0;j<64;j++)
o[rPx[j]]=i[j];
}
void MyPuffin::R_S(Byte *i, Byte *o)
{
for(int j=0;j<16;j++)
{
Byte b1=i[4*j]*8+i[4*j+1]*4+i[4*j+2]*2+i[4*j+3];
Byte b2[1];
b2[0]=DSbox[b1];
Byte b3[8];
T_8_1(b2,b3,1);
o[4*j+0]=b3[4];
o[4*j+1]=b3[5];
o[4*j+2]=b3[6];
o[4*j+3]=b3[7];
}
}
void MyPuffin::P(Byte *i, Byte *o)
{
for(int j=0;j<64;j++)
o[Px[j]]=i[j];
}
void MyPuffin::key(Byte *k, Byte *e)
{
int i,j;
Byte kt1[128];
Byte kt2[128];
memset(kt1,0,128);
memset(kt2,0,128);

for(i=0;i<128;i++)
kt1[i]=k[i];

for(j=0;j<64;j++)
e[j]=kt1[j];

for(i=1;i<33;i++)
{
for(j=0;j<128;j++)
kt2[j]=kt1[P128[j]-1];
//if(i==2||i==5||i==6||i==8)
{
for(j=0;j<128;j++)
{
// 1 2 3 5
if(j==0||j==1||j==2||j==4)
kt2[j]^=1;
}
}
for(j=0;j<64;j++)
e[64*i+j]=kt2[P64[j]-1];
for(j=0;j<128;j++)
kt1[j]=kt2[j];

Byte ccc[16];
T_1_4(e+64*i,ccc,64);
printf("\n%d轮密钥为\n",i+1);
printfblock(ccc,16);

}

}
void MyPuffin::T_8_1(Byte *i8, Byte *i1,int nlength)
{
int i=0;
Byte tt;
for(i=0;i<8*nlength;i++)
i1[i]=0;

for(i=0;i<nlength;i++)
{
tt=i8[i]&0x80;
if(tt==0x80)
i1[8*i+0]++;

tt=i8[i]&0x40;
if(tt==0x40)
i1[8*i+1]++;

tt=i8[i]&0x20;
if(tt==0x20)
i1[8*i+2]++;

tt=i8[i]&0x10;
if(tt==0x10)
i1[8*i+3]++;

tt=i8[i]&0x08;
if(tt==0x08)
i1[8*i+4]++;

tt=i8[i]&0x04;
if(tt==0x04)
i1[8*i+5]++;

tt=i8[i]&0x02;
if(tt==0x02)
i1[8*i+6]++;

tt=i8[i]&0x01;
if(tt==0x01)
i1[8*i+7]++;
}
}

void MyPuffin::T_8_1_1(Byte i8, Byte *i1)
{
int i=0;
Byte tt;
for(i=0;i<4;i++)
i1[i]=0;

tt=i8&0x08;
if(tt==0x08)
i1[0]++;

tt=i8&0x04;
if(tt==0x04)
i1[1]++;

tt=i8&0x02;
if(tt==0x02)
i1[2]++;

tt=i8&0x01;
if(tt==0x01)
i1[3]++;
}

void MyPuffin::T_1_8(Byte *i1,Byte *i8, int nlength)
{
int i=0;
for(i=0;i<nlength/8;i++)
{
i8[i]=i1[8*i+0]*128+i1[8*i+1]*64+i1[8*i+2]*32+i1[8*i+3]*16+i1[8*i+4]*8+i1[8*i+5]*4+i1[8*i+6]*2+i1[8*i+7];
}
}
void MyPuffin::T_1_4(Byte *i1,Byte *i4, int nlength)
{
int i=0;
for(i=0;i<nlength/4;i++)
{
i4[i]=i1[8*i+0]*8+i1[8*i+1]*4+i1[8*i+2]*2+i1[8*i+3];
}
}
void MyPuffin::printfblock(Byte * b,int nlength)
{
for(int i=0;i<nlength;i++)
printf("%2x ",b[i]);
printf("\n");
}
编译没有问题,但运行不了
...全文
114 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
渔舟唱晚, 2013-11-10
  • 打赏
  • 举报
回复
Yuixz 2013-11-09
  • 打赏
  • 举报
回复
fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory Error executing cl.exe. 运行结果是它
Yuixz 2013-11-09
  • 打赏
  • 举报
回复
csdn中不可以解决吗?大虾们,快来帮帮忙
不再相见 2013-11-09
  • 打赏
  • 举报
回复
可以到相关技术区发帖咨询下

3,881

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧