当前位置: 首页 > news >正文

创建app与网站的区别票付通app下载

创建app与网站的区别,票付通app下载,代运营主要做什么,如何将数据库导入网站文章目录 openssl3.2 - 官方demo学习 - digest - EVP_MD_demo.c概述笔记END openssl3.2 - 官方demo学习 - digest - EVP_MD_demo.c 概述 使用 SHA3-512 对多个buffer连续进行摘要, 最后得到一个摘要值 笔记 /*! \file EVP_MD_demo.c \note openssl3.2 - 官方demo学习 - dig…

文章目录

    • openssl3.2 - 官方demo学习 - digest - EVP_MD_demo.c
    • 概述
    • 笔记
    • END

openssl3.2 - 官方demo学习 - digest - EVP_MD_demo.c

概述

使用 SHA3-512 对多个buffer连续进行摘要, 最后得到一个摘要值

笔记

/*!
\file EVP_MD_demo.c
\note openssl3.2 - 官方demo学习 - digest - EVP_MD_demo.c
使用 SHA3-512 对多个buffer连续进行摘要, 最后得到一个摘要值
*//*-* Copyright 2021-2023 The OpenSSL Project Authors. All Rights Reserved.** Licensed under the Apache License 2.0 (the "License").  You may not use* this file except in compliance with the License.  You can obtain a copy* in the file LICENSE in the source distribution or at* https://www.openssl.org/source/license.html*//** Example of using EVP_MD_fetch and EVP_Digest* methods to calculate* a digest of static buffers*/#include <string.h>
#include <stdio.h>
#include <openssl/err.h>
#include <openssl/evp.h>#include "my_openSSL_lib.h"/*-* This demonstration will show how to digest data using* the soliloqy from Hamlet scene 1 act 3* The soliloqy is split into two parts to demonstrate using EVP_DigestUpdate* more than once.*/const char* hamlet_1 =
"To be, or not to be, that is the question,\n"
"Whether tis nobler in the minde to suffer\n"
"The ſlings and arrowes of outragious fortune,\n"
"Or to take Armes again in a sea of troubles,\n"
"And by opposing, end them, to die to sleep;\n"
"No more, and by a sleep, to say we end\n"
"The heart-ache, and the thousand natural shocks\n"
"That flesh is heir to? tis a consumation\n"
"Devoutly to be wished. To die to sleep,\n"
"To sleepe, perchance to dreame, Aye, there's the rub,\n"
"For in that sleep of death what dreams may come\n"
"When we haue shuffled off this mortal coil\n"
"Must give us pause. There's the respect\n"
"That makes calamity of so long life:\n"
"For who would bear the Ships and Scorns of time,\n"
"The oppressor's wrong, the proud man's Contumely,\n"
"The pangs of dispised love, the Law's delay,\n"
;
const char* hamlet_2 =
"The insolence of Office, and the spurns\n"
"That patient merit of the'unworthy takes,\n"
"When he himself might his Quietas make\n"
"With a bare bodkin? Who would fardels bear,\n"
"To grunt and sweat under a weary life,\n"
"But that the dread of something after death,\n"
"The undiscovered country, from whose bourn\n"
"No traveller returns, puzzles the will,\n"
"And makes us rather bear those ills we have,\n"
"Then fly to others we know not of?\n"
"Thus conscience does make cowards of us all,\n"
"And thus the native hue of Resolution\n"
"Is sickled o'er with the pale cast of Thought,\n"
"And enterprises of great pith and moment,\n"
"With this regard their currents turn awry,\n"
"And lose the name of Action. Soft you now,\n"
"The fair Ophelia? Nymph in thy Orisons\n"
"Be all my sins remember'd.\n"
;/* The known value of the SHA3-512 digest of the above soliloqy */
const unsigned char known_answer[] = {0xbb, 0x69, 0xf8, 0x09, 0x9c, 0x2e, 0x00, 0x3d,0xa4, 0x29, 0x5f, 0x59, 0x4b, 0x89, 0xe4, 0xd9,0xdb, 0xa2, 0xe5, 0xaf, 0xa5, 0x87, 0x73, 0x9d,0x83, 0x72, 0xcf, 0xea, 0x84, 0x66, 0xc1, 0xf9,0xc9, 0x78, 0xef, 0xba, 0x3d, 0xe9, 0xc1, 0xff,0xa3, 0x75, 0xc7, 0x58, 0x74, 0x8e, 0x9c, 0x1d,0x14, 0xd9, 0xdd, 0xd1, 0xfd, 0x24, 0x30, 0xd6,0x81, 0xca, 0x8f, 0x78, 0x29, 0x19, 0x9a, 0xfe,
};int demonstrate_digest(void)
{OSSL_LIB_CTX* _ossl_lib_ctx;int ret = 0;const char* _psz_option_properties = NULL;EVP_MD* _evp_md = NULL;EVP_MD_CTX* _evp_md_ctx = NULL;unsigned int digest_length;unsigned char* _p_digest_value = NULL;int j;_ossl_lib_ctx = OSSL_LIB_CTX_new();if (_ossl_lib_ctx == NULL) {fprintf(stderr, "OSSL_LIB_CTX_new() returned NULL\n");goto cleanup;}/** Fetch a message digest by name* The algorithm name is case insensitive.* See providers(7) for details about algorithm fetching*/_evp_md = EVP_MD_fetch(_ossl_lib_ctx,"SHA3-512", _psz_option_properties);if (_evp_md == NULL) {fprintf(stderr, "EVP_MD_fetch could not find SHA3-512.");goto cleanup;}/* Determine the length of the fetched digest type */digest_length = EVP_MD_get_size(_evp_md);if (digest_length <= 0) {fprintf(stderr, "EVP_MD_get_size returned invalid size.\n");goto cleanup;}_p_digest_value = OPENSSL_malloc(digest_length);if (_p_digest_value == NULL) {fprintf(stderr, "No memory.\n");goto cleanup;}/** Make a message digest context to hold temporary state* during digest creation*/_evp_md_ctx = EVP_MD_CTX_new();if (_evp_md_ctx == NULL) {fprintf(stderr, "EVP_MD_CTX_new failed.\n");goto cleanup;}/** Initialize the message digest context to use the fetched* digest provider*/if (EVP_DigestInit(_evp_md_ctx, _evp_md) != 1) {fprintf(stderr, "EVP_DigestInit failed.\n");goto cleanup;}/* Digest parts one and two of the soliloqy */if (EVP_DigestUpdate(_evp_md_ctx, hamlet_1, strlen(hamlet_1)) != 1) {fprintf(stderr, "EVP_DigestUpdate(hamlet_1) failed.\n");goto cleanup;}if (EVP_DigestUpdate(_evp_md_ctx, hamlet_2, strlen(hamlet_2)) != 1) {fprintf(stderr, "EVP_DigestUpdate(hamlet_2) failed.\n");goto cleanup;}if (EVP_DigestFinal(_evp_md_ctx, _p_digest_value, &digest_length) != 1) {fprintf(stderr, "EVP_DigestFinal() failed.\n");goto cleanup;}for (j = 0; j < (int)digest_length; j++) {fprintf(stdout, "%02x", _p_digest_value[j]);}fprintf(stdout, "\n");/* Check digest_value against the known answer */if ((size_t)digest_length != sizeof(known_answer)) {fprintf(stdout, "Digest length(%d) not equal to known answer length(%lu).\n",digest_length, (unsigned long)sizeof(known_answer));}else if (memcmp(_p_digest_value, known_answer, digest_length) != 0) {for (j = 0; j < sizeof(known_answer); j++) {fprintf(stdout, "%02x", known_answer[j]);}fprintf(stdout, "\nDigest does not match known answer\n");}else {fprintf(stdout, "Digest computed properly.\n");ret = 1;}cleanup:if (ret != 1)ERR_print_errors_fp(stderr);/* OpenSSL free functions will ignore NULL arguments */EVP_MD_CTX_free(_evp_md_ctx);OPENSSL_free(_p_digest_value);EVP_MD_free(_evp_md);OSSL_LIB_CTX_free(_ossl_lib_ctx);return ret;
}int main(void)
{return demonstrate_digest() ? EXIT_SUCCESS : EXIT_FAILURE;
}

END

http://www.yayakq.cn/news/363526/

相关文章:

  • 网站建设有哪些环节现代广告创意设计
  • 大型建设网站制作淘宝网现状 网站建设
  • 做网站的入什么科目抖音网站开发
  • 开通微信公众号要钱吗seo推广优化收费
  • 写作网站投稿平台长沙百度首页排名
  • 建网站软件最新国外做衣服网站
  • 省级精品课程网站中国最好的猎头公司
  • 南阳网站排名公司wordpress中文字体插件
  • 重庆营销型网站建设宠物商品销售网站开发背景
  • 用手机可以做网站嘛企业查询系统 工商
  • psd数据网站备案期间怎么做网站
  • 甘孜州建设局门户网站给网站添加后台
  • 加强意识形态建设 办好政协网站甘肃系统建站怎么用
  • 咨询聊城做网站进出口网站贸易平台有哪些
  • 山东网站建设的方案室内设计培训班排行榜学校
  • 做网站设计师的感想六安seo曝光行者seo
  • 天津网站优化公司哪家好做网站后台用什么软件
  • 建企业网站行业网小程序登录不上去怎么办
  • 天津怎样做网站推广我为群众办实事实践活动
  • 自己如何搭建网站资料查询网站怎么做
  • 开源程序网站网站wap转换
  • 做网站一月工资美食网站开发的背景
  • 移动商城个人中心哈尔滨关键词优化效果
  • 门户网站案例分析制作一个网站需要哪些步骤
  • 深圳网络营销网站设计专做茶叶的网站
  • 建网站的客户微网站不能分享朋友圈
  • 企业做什么需要有网站wordpress模板如何安装教程视频教程
  • 苏州住房和城乡建设局网站首页百度快照首页
  • 做网站阳泉购物网站创业时是如何做宣传的
  • 企业网站的建设对于网络品牌的塑造作用做石材网站步骤