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

怎么做记步数的程序到网站推广有什么好方法

怎么做记步数的程序到网站,推广有什么好方法,常州市网站制作,静态网站开发技术和动态网站开发技术的区别加解密(C/C) 以AES 256密钥为例,完成加解密。具体的场景介绍及支持的算法规格。 在CMake脚本中链接相关动态库 target_link_libraries(entry PUBLIC libhuks_ndk.z.so)开发步骤 生成密钥 指定密钥别名。初始化密钥属性集。调用OH_Huks_GenerateKeyItem生成密钥)…

加解密(C/C++)

以AES 256密钥为例,完成加解密。具体的场景介绍及支持的算法规格。

在CMake脚本中链接相关动态库

   target_link_libraries(entry PUBLIC libhuks_ndk.z.so)

开发步骤

生成密钥

  1. 指定密钥别名。
  2. 初始化密钥属性集。
  3. 调用OH_Huks_GenerateKeyItem生成密钥)。
  4. 开发前请熟悉鸿蒙开发指导文档gitee.com/li-shizhen-skin/harmony-os/blob/master/README.md点击或者复制转到。

除此之外,开发者也可以参考[密钥导入],导入已有的密钥。

加密

  1. 获取密钥别名。
  2. 获取待加密的数据。
  3. 调用[OH_Huks_InitParamSet]指定算法参数配置。 在下方示例中,使用算法AES进行加密时,必须要选择其对应分组模式以及填充模式,用例中选取的分组模式为CBC、填充模式为PKCS7,此时必须要填参数IV。
  4. 调用[OH_Huks_InitSession]初始化密钥会话,并获取会话的句柄handle。
  5. 调用[OH_Huks_FinishSession]结束密钥会话,获取加密后的密文。

解密

  1. 获取密钥别名。
  2. 获取待解密的密文。
  3. 调用[OH_Huks_InitParamSet]指定算法参数配置。 在下方示例中,使用算法AES进行解密时,必须要选择其对应分组模式以及填充模式,用例中选取的分组模式为CBC、填充模式为PKCS7,此时必须要填参数IV。
  4. 调用[OH_Huks_InitSession]初始化密钥会话,并获取会话的句柄handle。
  5. 调用[OH_Huks_FinishSession]结束密钥会话,获取解密后的数据。
  6. HarmonyOS与OpenHarmony鸿蒙文档籽料:mau123789是v直接拿

QQ截图20240705210937.png

删除密钥

当密钥废弃不用时,需要调用OH_Huks_DeleteKeyItem删除密钥。

#include "huks/native_huks_api.h"
#include "huks/native_huks_param.h"
#include <string.h>
OH_Huks_Result InitParamSet(struct OH_Huks_ParamSet **paramSet,const struct OH_Huks_Param *params,uint32_t paramCount)
{OH_Huks_Result ret = OH_Huks_InitParamSet(paramSet);if (ret.errorCode != OH_HUKS_SUCCESS) {return ret;}ret = OH_Huks_AddParams(*paramSet, params, paramCount);if (ret.errorCode != OH_HUKS_SUCCESS) {OH_Huks_FreeParamSet(paramSet);return ret;}ret = OH_Huks_BuildParamSet(paramSet);if (ret.errorCode != OH_HUKS_SUCCESS) {OH_Huks_FreeParamSet(paramSet);return ret;}return ret;
}
static const uint32_t IV_SIZE = 16;
static uint8_t IV[IV_SIZE] = { 0 }; // this is a test value, for real use the iv should be different every time
static struct OH_Huks_Param g_genEncDecParams[] = {{.tag = OH_HUKS_TAG_ALGORITHM,.uint32Param = OH_HUKS_ALG_AES}, {.tag = OH_HUKS_TAG_PURPOSE,.uint32Param = OH_HUKS_KEY_PURPOSE_ENCRYPT | OH_HUKS_KEY_PURPOSE_DECRYPT}, {.tag = OH_HUKS_TAG_KEY_SIZE,.uint32Param = OH_HUKS_AES_KEY_SIZE_256}, {.tag = OH_HUKS_TAG_PADDING,.uint32Param = OH_HUKS_PADDING_NONE}, {.tag = OH_HUKS_TAG_BLOCK_MODE,.uint32Param = OH_HUKS_MODE_CBC}
};
static struct OH_Huks_Param g_encryptParams[] = {{.tag = OH_HUKS_TAG_ALGORITHM,.uint32Param = OH_HUKS_ALG_AES}, {.tag = OH_HUKS_TAG_PURPOSE,.uint32Param = OH_HUKS_KEY_PURPOSE_ENCRYPT}, {.tag = OH_HUKS_TAG_KEY_SIZE,.uint32Param = OH_HUKS_AES_KEY_SIZE_256}, {.tag = OH_HUKS_TAG_PADDING,.uint32Param = OH_HUKS_PADDING_NONE}, {.tag = OH_HUKS_TAG_BLOCK_MODE,.uint32Param = OH_HUKS_MODE_CBC}, {.tag = OH_HUKS_TAG_IV,.blob = {.size = IV_SIZE,.data = (uint8_t *)IV // this is a test value, for real use the iv should be different every time }}
};
static struct OH_Huks_Param g_decryptParams[] = {{.tag = OH_HUKS_TAG_ALGORITHM,.uint32Param = OH_HUKS_ALG_AES}, {.tag = OH_HUKS_TAG_PURPOSE,.uint32Param = OH_HUKS_KEY_PURPOSE_DECRYPT}, {.tag = OH_HUKS_TAG_KEY_SIZE,.uint32Param = OH_HUKS_AES_KEY_SIZE_256}, {.tag = OH_HUKS_TAG_PADDING,.uint32Param = OH_HUKS_PADDING_NONE}, {.tag = OH_HUKS_TAG_BLOCK_MODE,.uint32Param = OH_HUKS_MODE_CBC}, {.tag = OH_HUKS_TAG_IV,.blob = {.size = IV_SIZE,.data = (uint8_t *)IV // this is a test value, for real use the iv should be different every time }}
};
static const uint32_t AES_COMMON_SIZE = 1024;
OH_Huks_Result HksAesCipherTestEncrypt(const struct OH_Huks_Blob *keyAlias,const struct OH_Huks_ParamSet *encryptParamSet, const struct OH_Huks_Blob *inData, struct OH_Huks_Blob *cipherText)
{uint8_t handleE[sizeof(uint64_t)] = {0};struct OH_Huks_Blob handleEncrypt = {sizeof(uint64_t), handleE};OH_Huks_Result ret = OH_Huks_InitSession(keyAlias, encryptParamSet, &handleEncrypt, nullptr);if (ret.errorCode != OH_HUKS_SUCCESS) {return ret;}ret = OH_Huks_FinishSession(&handleEncrypt, encryptParamSet, inData, cipherText);return ret;
}
OH_Huks_Result HksAesCipherTestDecrypt(const struct OH_Huks_Blob *keyAlias,const struct OH_Huks_ParamSet *decryptParamSet, const struct OH_Huks_Blob *cipherText, struct OH_Huks_Blob *plainText,const struct OH_Huks_Blob *inData)
{uint8_t handleD[sizeof(uint64_t)] = {0};struct OH_Huks_Blob handleDecrypt = {sizeof(uint64_t), handleD};OH_Huks_Result ret = OH_Huks_InitSession(keyAlias, decryptParamSet, &handleDecrypt, nullptr);if (ret.errorCode != OH_HUKS_SUCCESS) {return ret;}ret = OH_Huks_FinishSession(&handleDecrypt, decryptParamSet, cipherText, plainText);return ret;
}
static napi_value EncDecKey(napi_env env, napi_callback_info info)
{char tmpKeyAlias[] = "test_enc_dec";struct OH_Huks_Blob keyAlias = { (uint32_t)strlen(tmpKeyAlias), (uint8_t *)tmpKeyAlias };struct OH_Huks_ParamSet *genParamSet = nullptr;struct OH_Huks_ParamSet *encryptParamSet = nullptr;struct OH_Huks_ParamSet *decryptParamSet = nullptr;OH_Huks_Result ohResult;do {/* 1. Generate Key *//** 模拟生成密钥场景* 1.1. 确定密钥别名*//** 1.2. 获取生成密钥算法参数配置*/ohResult = InitParamSet(&genParamSet, g_genEncDecParams, sizeof(g_genEncDecParams) / sizeof(OH_Huks_Param));if (ohResult.errorCode != OH_HUKS_SUCCESS) {break;}/** 1.3. 调用generateKeyItem*/ohResult = OH_Huks_GenerateKeyItem(&keyAlias, genParamSet, nullptr);if (ohResult.errorCode != OH_HUKS_SUCCESS) {break;}/* 2. Encrypt *//** 模拟加密场景* 2.1. 获取密钥别名*//** 2.2. 获取待加密的数据*//** 2.3. 获取加密算法参数配置*/ohResult = InitParamSet(&encryptParamSet, g_encryptParams, sizeof(g_encryptParams) / sizeof(OH_Huks_Param));if (ohResult.errorCode != OH_HUKS_SUCCESS) {break;}char tmpInData[] = "AES_ECB_INDATA_1";struct OH_Huks_Blob inData = { (uint32_t)strlen(tmpInData), (uint8_t *)tmpInData };uint8_t cipher[AES_COMMON_SIZE] = {0};struct OH_Huks_Blob cipherText = {AES_COMMON_SIZE, cipher};/** 2.4. 调用initSession获取handle*//** 2.5. 调用finishSession获取加密后的密文*/ohResult = HksAesCipherTestEncrypt(&keyAlias, encryptParamSet, &inData, &cipherText);if (ohResult.errorCode != OH_HUKS_SUCCESS) {break;}/* 3. Decrypt *//** 模拟解密场景* 3.1. 获取密钥别名*//** 3.2. 获取待解密的密文*//** 3.3. 获取解密算法参数配置*/ohResult = InitParamSet(&decryptParamSet, g_decryptParams, sizeof(g_decryptParams) / sizeof(OH_Huks_Param));if (ohResult.errorCode != OH_HUKS_SUCCESS) {break;}uint8_t plain[AES_COMMON_SIZE] = {0};struct OH_Huks_Blob plainText = {AES_COMMON_SIZE, plain};/** 3.4. 调用initSession获取handle*//** 3.5. 调用finishSession获取解密后的数据*/ohResult = HksAesCipherTestDecrypt(&keyAlias, decryptParamSet, &cipherText, &plainText, &inData);} while (0);/* 4. Delete Key *//** 模拟删除密钥场景* 4.1. 获取密钥别名*//** 4.2. 调用deleteKeyItem删除密钥    */(void)OH_Huks_DeleteKeyItem(&keyAlias, genParamSet);OH_Huks_FreeParamSet(&genParamSet);OH_Huks_FreeParamSet(&encryptParamSet);OH_Huks_FreeParamSet(&decryptParamSet);napi_value ret;napi_create_int32(env, ohResult.errorCode, &ret);return ret;
}
http://www.wangmingla.cn/news/40406.html

相关文章:

  • 用一部手机制作网站佛山seo培训机构
  • 商昊网站建设成都官网seo费用
  • 网站说服力营销型网站策划视频网站推广
  • java实现大型门户网站开发经验苏州疫情最新通知
  • 做美容美容院网站的费用北京seo多少钱
  • 自营b2c模式的网站有哪些百度识图网页版入口
  • 乐之网站制作衡阳网站优化公司
  • 手机电脑版淘宝网址北京关键词优化平台
  • 仿qq商城版淘宝客网站源码模板+带程序后台文章dede织梦企业程序网站如何赚钱
  • bootstrap 自适应网站推广引流平台
  • 手游网站建设的宗旨全网关键词云在哪里看
  • 有广告的网站网站怎么提升关键词排名
  • iis怎么给网站设置权限seo网址
  • 深圳华强北手表各品牌批发福州百度快照优化
  • 专门做图片的网站ip网站查询服务器
  • 公司网站建设建议做网站的网络公司
  • 什么专业学网站建设百度有效点击软件
  • b2c模式的电子商务网站销售系统
  • 织梦可以做婚纱影楼网站吗网站搭建免费
  • 怎么样备份网站数据网络推广 公司 200个网站
  • 黄骅市人民医院官网百度关键词优化怎么做
  • 公司网站工商备案怎么做推广平台排行榜有哪些
  • 住房和创新建设部网站小程序开发平台
  • 做食品生产的网站关键词网站排名软件
  • 贵港网站营销腾讯企点账户中心
  • 网站开发工具有哪些推广软文300字范文
  • 学做包子馒头的网站启信聚客通网络营销策划
  • 做信息安全的网站网站设计公司苏州
  • 网站推广的基本手段优化大师好用吗
  • 网页设计模板之家克州seo整站排名