aes_test.cpp

来自「算法从speakfs提取」· C++ 代码 · 共 42 行

CPP
42
字号

#include <stdio.h>
#include <string.h>

#include "aes.h"


int main(void)
{
    char in[]="I have had my best love before, but I did not treasure her. When I lost her, I fell regretful. It is the most painful matter in this world. If God can give me another chance, I will say 3 words to her --- I love you. If you have to give a time limit to this love, I hope it is 10 thousand years";  
	char out[295];
	unsigned char key[]="1234567890123456";
	int len;
	len=strlen(in);
	aes_ctx ectx;
	aes_enc_key(key, 16, &ectx);
	aes_enc_blk((unsigned char *)in, (unsigned char *)out, &ectx);
	for (int i=0; i<294; i++)
	{
		printf("%c",in[i]);
	}
	printf("\n");
	for (i=0; i<294; i++)
	{
		printf("%c ",out[i]);
	}
	printf("\n\n\n");
	aes_dec_key(key, 16, &ectx);
	aes_dec_blk((unsigned char *)out, (unsigned char *)in, &ectx);
	for (i=0; i<294; i++)
	{
		printf("%2x",out[i]&0xff);
	}
	printf("\n");
	for (i=0; i<294; i++)
	{
		printf("%c",in[i]);
	}
	printf("\n");
    return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?