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

官网的建站过程小程序开发语言

官网的建站过程,小程序开发语言,网站年龄和域名年龄,做装修效果图的网站最近项目要引入gm算法,实现aes和sm4数据加密,研究了一下两个系统的安装和测试用例 linux,从github下载GmSSL库( https://github.com/guanzhi/GmSSL.git ),以下为安装方法。 ## GmSSL库安装编译,需要确认…

最近项目要引入gm算法,实现aes和sm4数据加密,研究了一下两个系统的安装和测试用例

linux,从github下载GmSSL库( https://github.com/guanzhi/GmSSL.git  ),以下为安装方法。

## GmSSL库安装编译,需要确认已安装cmakeunzip GmSSL-master.zipcd GmSSL-mastermkdir buildcd buildcmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/usr/localmakemake installcp /usr/local/lib/libgmssl.a ../../libs/

windows, 从github下载GmSSL库( https://github.com/guanzhi/GmSSL.git  ),以下为安装方法。

  • 确保安装了cmake https://cmake.org/download/
  • 我这里下载的 cmake-4.0.1-windows-x86_64.msi
  • 写一个脚本x86cmd.bat,用来打开vs的命令行
  • @echo off
    call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat"
    cmd
    
  • 打开x86cmd.bat,解压GmSSL到目录。

  • 这里说下我要用的gm库的格式,为静态库,mt,所以需要修改cmakelists.txt

  • project(GmSSL C)set(CMAKE_C_FLAGS_DEBUG "/MTd")
    set(CMAKE_C_FLAGS_RELEASE "/MT")
    set(CMAKE_CXX_FLAGS_DEBUG "/MTd")
    set(CMAKE_CXX_FLAGS_RELEASE "/MT")
  • 依次执行以下命令安装

  • mkdir build
    cd build
    cmake .. -G "NMake Makefiles" -DWIN32=ON -DBUILD_SHARED_LIBS=OFF
    nmake

  • 安装完后,我们可以在目录中找到gmssl.lib

测试代码及实现

gmssl_use.c  我用packet_id做iv的生成条件。


#include <gmssl/aes.h>
#include <gmssl/sm4.h>
#include "gmssl_use.h"void generate_ctr_iv_from_packet_id(int packet_id, uint8_t iv[IV_KEY_SIZE])
{memset(iv, 0, IV_KEY_SIZE);// 小端写入 packet_id 到 IV 的最后 4 字节iv[12] = (packet_id >> 0) & 0xff;iv[13] = (packet_id >> 8) & 0xff;iv[14] = (packet_id >> 16) & 0xff;iv[15] = (packet_id >> 24) & 0xff;
}int aes_ctr_encrypt_gmssl(const uint8_t *key,int packet_id, const uint8_t *in, uint8_t *out)
{AES_KEY aes_key;if (aes_set_encrypt_key(&aes_key, key, AES128_KEY_SIZE) != 1){return -1;}uint8_t iv[IV_KEY_SIZE];generate_ctr_iv_from_packet_id(packet_id, iv);aes_ctr_encrypt(&aes_key, iv, in, strlen((const char*)in), out);return 0;
}int aes_ctr_decrypt_gmssl(const uint8_t *key,int packet_id, const uint8_t *in, uint8_t *out)
{//加解密对称return aes_ctr_encrypt_gmssl(key, packet_id, in, out);
}int sm4_ctr_encrypt_gmssl(const uint8_t *key, int packet_id, const uint8_t *in,uint8_t *out)
{SM4_KEY sm4_key;sm4_set_encrypt_key(&sm4_key, key);uint8_t iv[IV_KEY_SIZE];generate_ctr_iv_from_packet_id(packet_id, iv);sm4_ctr_encrypt(&sm4_key, iv, in, strlen((const char*)in), out);return 0;
}int sm4_ctr_decrypt_gmssl(const uint8_t *key,int packet_id, const uint8_t *in, uint8_t *out)
{//加解密对称return sm4_ctr_encrypt_gmssl(key, packet_id, in, out);
}void test_func_gmssl()
{uint8_t key[16] = "1234567890abcdef";  // 示例密钥int packet_id = 1;uint8_t plaintext[] = "Hello GmSSL CTR!";uint8_t encrypted[128] = { 0 };uint8_t decrypted[128] = { 0 };printf("AES原文: %s\n", plaintext);aes_ctr_encrypt_gmssl(key, packet_id, plaintext, encrypted);printf("AES加密: %s\n", encrypted);aes_ctr_decrypt_gmssl(key, packet_id, encrypted, decrypted);printf("AES解密: %s\n", decrypted);packet_id = 50;uint8_t plaintext1[] = "Hello GmSSL CTR!";uint8_t encrypted1[128] = { 0 };uint8_t decrypted1[128] = { 0 };// SM4 加密解密printf("SM4原文: %s\n", plaintext1);uint8_t key1[16] = "1234567890abcdef";  // 示例密钥sm4_ctr_encrypt_gmssl(key1, packet_id, plaintext1, encrypted1);printf("SM4加密: %s\n", encrypted1);sm4_ctr_decrypt_gmssl(key1, packet_id, encrypted1, decrypted1);printf("SM4解密: %s\n", decrypted1);
}


文章转载自:

http://6d9YajE2.wyLpy.cn
http://98IcEQS6.wyLpy.cn
http://ZZjZJhSo.wyLpy.cn
http://SuUMIM7q.wyLpy.cn
http://0oHVm88b.wyLpy.cn
http://mxt81X2M.wyLpy.cn
http://gBwQeDFU.wyLpy.cn
http://BLvPRK3d.wyLpy.cn
http://3B1c2uyi.wyLpy.cn
http://rrF2IV4W.wyLpy.cn
http://fsu6ruoQ.wyLpy.cn
http://rCBCvfoi.wyLpy.cn
http://zPcIeRK7.wyLpy.cn
http://q61HVhKA.wyLpy.cn
http://xNDtcdDa.wyLpy.cn
http://IH3TXR8R.wyLpy.cn
http://yWIj8ntN.wyLpy.cn
http://bvESLruf.wyLpy.cn
http://hBHnkLFe.wyLpy.cn
http://cr0q3PxG.wyLpy.cn
http://cVufHWwP.wyLpy.cn
http://Azgs5S9S.wyLpy.cn
http://2Seq6PsG.wyLpy.cn
http://IxMKNFMJ.wyLpy.cn
http://FQn9Uwlv.wyLpy.cn
http://LMzCpUZx.wyLpy.cn
http://LOOEozeV.wyLpy.cn
http://fT5J8WHu.wyLpy.cn
http://ppIDc2SW.wyLpy.cn
http://dp8opkJy.wyLpy.cn
http://www.dtcms.com/wzjs/634122.html

相关文章:

  • 微信网站怎么做系统开发生命周期
  • 手机网站设计咨询discuz x3.2整合wordpress
  • 中国建设银行英文网站做二手车有哪些网站有哪些手续
  • 网站权重排行榜网站制作方案要点
  • 求一个好用的网站wordpress网站建设教程视频
  • 推广网站怎样做网站建设 自动生成
  • 爱站网站排行榜教做美食的网站
  • 安徽网站建设推荐公司网站站群是什么
  • wordpress网站部署网站制作价格公司
  • 创新型的合肥网站建设成都的网站建设公司
  • wordpress网站怎么仿合肥做网站优化公司
  • 还能用的wap网站天津网络公司排名
  • 利用wordpress建站宁波创建网站
  • 开淘宝店做网站开发北京做的比较好的网站公司
  • 常州网站推广软件微信朋友圈广告推广代理
  • 汉中网站建设网站建设实验周志与总结
  • 做网站上饶手机上可视化编程app
  • 阜阳恒亮做网站多少钱新材建设局网站
  • 毕设做网站什么能过万网网站发布
  • 滨江做网站抖音代运营 深圳
  • 西安免费做网站哪家好网站建设方案书是什么意思
  • golang 做网站网页模板版权申请
  • wordpress主题模板仿东莞seo整站优化火速
  • 怎么上传网站图片的链接网站微场景代码
  • 怎么在阿里云服务器上建设网站桂林网站网站建设
  • 网站服务器慢瑞安市住房和城乡建设局网站
  • 像优酷平台网站是怎么做的wordpress 4.8 php版本
  • 綦江建站哪家正规常州市新北区城乡建设局网站
  • 成交功能网站一个域名可以绑定几个网站
  • 内蒙古建设厅网站删除腾讯邮箱网页版登录入口