ircle(fword &s,word &v)
{
for(int t = 0;t<32;t++)
v[t] = s[t];
}
void fword_to_word(fword &x,word y[4])//四字转化为单字
{
fword temp;
for(int o = 0;o<4;o++)
{
temp=x>>o*32;
circle(temp,y[3-o]); //注意是反着放的
}
}
word Rotl(word &v,int gh)//左移函数
{
word stemp;
word ktemp;
stemp = v>>24-gh*8;
ktemp = v<<8+gh*8;
return stemp|ktemp;
}
word Rcon[10] = {0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000,
0x20000000, 0x40000000, 0x80000000, 0x1b000000, 0x36000000}; //轮常数
word byte_to_word(byte r[],int j)//状态列字节转换为字的函数
{
word n(r[0+4*j].to_string()+r[1+4*j].to_string()+r[2+4*j].to_string()+r[3+4*j].to_string());
//cout< return n;
}
word Byte_to_word(byte r[],int gg)//状态行字节转化为字的函数
{
word n(r[0+gg].to_string()+r[4+gg].to_string()+r[8+gg].to_string()+r[12+gg].to_string());
//cout< return n;
}
word SubByte(word &vv)//S盒变换
{
byte p[4];
// cout< // cout< for(int u = 0;u<4;u++)
{
int col = vv[u*8]+vv[u*8+1]*2+vv[u*8+2]*4+vv[u*8+3]*8; //注意二进制站位和string不同
int row = vv[u*8+4]+vv[u*8+5]*2+vv[u*8+6]*4+vv[u*8+7]*8;
// cout<