酷代码 AI
菜单
服务商

c语言sm4加解密

#include <stdio.h> #include <string.h> #include "sm4.h" int main() { unsigned char key[16] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10}; unsigned char plaintext[16] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10}; unsigned char ciphertext[16]; unsigned char decrypttext[16]; // Encrypt sm4_context ctx; sm4_setkey_enc(&ctx, key); sm4_crypt_ecb(&ctx, 1, 16, plaintext, ciphertext); printf("Cipher Text:\n"); for(int i=0; i<16; i++) { printf("%02x", ciphertext[i]); } printf("\n"); // Decrypt sm4_setkey_dec(&ctx, key); sm4_crypt_ecb(&ctx, 0, 16, ciphertext, decrypttext); printf("Plain Text:\n"); for(int i=0; i<16; i++) { printf("%02x", decrypttext[i]); } printf("\n"); return 0; } [2024-11-08 09:28:02 | AI写代码神器 | 600点数解答]

相关提问
实用工具查看更多
今日油价 [生活类]
图片互转base64 [开发类]
时间转换器 [开发类]
数独游戏 [娱乐类]
经典推箱子 [娱乐类]
AI摸鱼五子棋 [娱乐类]