老师给了一段给数据加密的代码怎么用

#include "msp430x26x.h"
#include "aes.h"
#include
#include
#include

int main( void )
{
int i;
int len;
unsigned char state[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
// unsigned char state[] ="AES加密AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
//unsigned char ciphertext[] = {0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30,
// 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a};
unsigned char key[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};

unsigned char data[128];
FILE* fpsrc,*fpdst;

if( (fpsrc = fopen("f:\cp.exe","rb" )) == NULL)
{
printf("Open SRC File Error!\n");
exit( 1 );
}
fpdst = fopen( "f:\test_decrypt.exe","wb" );
while( ( len = fread( data,1,sizeof( data ),fpsrc )) > 0 )
{
if( len < sizeof( data ))
{
printf("Go to file end!\n");
}
aes_decrypt( data,key);
fwrite( data,1,sizeof( data ),fpdst );
memset( data,0,sizeof(data));
}
fclose( fpsrc);
fclose( fpdst );
aes_encrypt(state,key);
//aes_decrypt(state,key);

printf("%s\n",state );
for( i = 0; i < sizeof( state ); ++i )
{
printf("0x%02x\t",state[i] );
}

aes_decrypt(state,key);
for( i = 0; i < sizeof( state ); ++i )
{
printf("0x%02x\t",state[i] );
}

printf("%s\n",state );
return 0;
}
还有一个.c和.h的文件,用devc++运行main函数显示没有msp430x26x.h

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!