blowfish加解密算法源码(C语言实现)
加解密原理可以参考文章:BlowFish加解密原理与代码实现
调用示例:
- #include <stdio.h>
- #include "blowfish.h"
- void main(void) {
- uint32_t L = 1, R = 2;
- BLOWFISH_CTX ctx;
- Blowfish_Init (&ctx, (uint8_t *)"TESTKEY", 7);
- Blowfish_Encrypt(&ctx, &L, &R);
- printf("%08lX %08lX\n", (long unsigned int)L, (long unsigned int)R);
- if (L == 0xDF333FD2L && R == 0x30A71BB4L)
- printf("Test encryption OK.\n");
- else
- printf("Test encryption failed.\n");
- Blowfish_Decrypt(&ctx, &L, &R);
- if (L == 1 && R == 2)
- printf("Test decryption OK.\n");
- else
- printf("Test decryption failed.\n");
- }
复制代码
blowfish加解密算法源码(C语言实现)
游客,本帖隐藏的内容需要积分高于 2 才可浏览,您当前积分为 0
提取码下载:
|