OpenSSL摘要生成测试

#include
#include
#include
#include

#include


/* 生成摘要 */
void digest_test() {
uint8_t md_value[EVP_MAX_MD_SIZE];
EVP_MD_CTX md_ctx;


char* msg1 = "Test Message1";
char* msg2 = "Test Message2";
EVP_MD_CTX_init(&md_ctx);
EVP_DigestInit(&md_ctx, EVP_md5());
EVP_DigestUpdate(&md_ctx, msg1, strlen(msg1));
EVP_DigestUpdate(&md_ctx, msg2, strlen(msg2));


uint32_t val_len;
EVP_DigestFinal(&md_ctx, md_value, &val_len);


printf("摘要为:");
for (int i = 0; i < val_len; i++) {
printf("0x%02x ", md_value[i]);
}


EVP_MD_CTX_cleanup(&md_ctx);
printf("\n-----------------------\n");
}

你可能感兴趣的:(PKI基础知识)