📄 test.c
字号:
#include <stdio.h>
#include <stdlib.h>
#include "../include/blowfish.h"
int main(int argc, char *argv[])
{
puts("Blowfish testing function...");
blowfish_context_t *ctx = (blowfish_context_t *)malloc(sizeof(blowfish_context_t));
if(!ctx) {
puts("Could not allocate enough memory!");
return -1;
}
blowfish_initiate(ctx, "TESTKEY", 7);
unsigned long hi = 1, lo = 2;
blowfish_encryptblock(ctx, &hi, &lo);
printf("Encoded: %08lX %08lX\n", hi, lo);
if((hi == 0xDF333FD2) && (lo == 0x30A71BB4))
puts("Encryption Test Passed");
else puts("Encryption Test Failed");
blowfish_decryptblock(ctx, &hi, &lo);
if((hi == 1) && (lo == 2))
puts("Decryption Test Passed");
else puts("Decryption Test Failed");
puts("Done!");
blowfish_clean(ctx);
free(ctx);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -