UE5中一机一码功能
创建蓝图函数库
1、获取第一个有效的硬盘ID
// Fill out your copyright notice in the Description page of Project Settings.#pragma once#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "GetDiskIDClass.generated.h"/*** */
UCLASS()
class OPENTEST_API UGetDiskIDClass : public UBlueprintFunctionLibrary
{GENERATED_BODY()
public:UFUNCTION(BlueprintCallable)static FString GetFirstDiskID();
};
// Fill out your copyright notice in the Description page of Project Settings.#include "GetDiskIDClass.h"#include <comutil.h>FString UGetDiskIDClass::GetFirstDiskID()
{FString SerialNumber;for (int DriveNumber = 0; DriveNumber < 16; ++DriveNumber) {FString Drive = FString::Printf(TEXT("\\\\.\\PhysicalDrive%d"), DriveNumber);HANDLE hDevice = CreateFile(*Drive, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);if (hDevice != INVALID_HANDLE_VALUE) {STORAGE_PROPERTY_QUERY storageQuery;memset(&storageQuery, 0, sizeof(storageQuery));storageQuery.PropertyId = StorageDeviceProperty;storageQuery.QueryType = PropertyStandardQuery;BYTE buffer[4096];DWORD bytesReturned = 0;if (DeviceIoControl(hDevice, IOCTL_STORAGE_QUERY_PROPERTY, &storageQuery, sizeof(storageQuery), &buffer, sizeof(buffer), &bytesReturned, NULL)) {STORAGE_DESCRIPTOR_HEADER* header = (STORAGE_DESCRIPTOR_HEADER*)buffer;if (header->Size > 0 && header->Size <= bytesReturned) {STORAGE_DEVICE_DESCRIPTOR* deviceDescriptor = (STORAGE_DEVICE_DESCRIPTOR*)buffer;if (deviceDescriptor->SerialNumberOffset > 0) {SerialNumber = FString(ANSI_TO_TCHAR((char*)deviceDescriptor + deviceDescriptor->SerialNumberOffset));}}}CloseHandle(hDevice);if (!SerialNumber.IsEmpty()) {return SerialNumber;}}}// 如果没有找到有效的硬盘ID,返回一个空字符串return FString("");
}
2、获取第一个有效的Mac地址
// Fill out your copyright notice in the Description page of Project Settings.#pragma once#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "GetFirstMacAddrClass.generated.h"/*** */
UCLASS()
class OPENTEST_API UGetFirstMacAddrClass : public UBlueprintFunctionLibrary
{GENERATED_BODY()
public:UFUNCTION(BlueprintCallable)static FString GetFirstMac();
};
// Fill out your copyright notice in the Description page of Project Settings.#include "GetFirstMacAddrClass.h"#include <Windows.h>
#include <IPHlpApi.h>FString UGetFirstMacAddrClass::GetFirstMac()
{IP_ADAPTER_INFO IpAddresses[16];ULONG OutBufferLength = sizeof(IP_ADAPTER_INFO) * 16;// Read the adaptersuint32 RetVal = GetAdaptersInfo(IpAddresses, &OutBufferLength);if (RetVal == NO_ERROR){PIP_ADAPTER_INFO AdapterList = IpAddresses;// Walk the set of addresses to find the first valid MAC addresswhile (AdapterList){// If there is an address to readif (AdapterList->AddressLength > 0){TArray<uint8> MacAddr;MacAddr.AddZeroed(AdapterList->AddressLength);FMemory::Memcpy(MacAddr.GetData(), AdapterList->Address, AdapterList->AddressLength);FString Address;for (TArray<uint8>::TConstIterator it(MacAddr); it; ++it){Address += FString::Printf(TEXT("%02x"), *it);}// Return the first valid MAC address foundreturn Address;}AdapterList = AdapterList->Next;}}// If no valid MAC address is found, return an empty stringreturn FString("");
}
3、加密
// Fill out your copyright notice in the Description page of Project Settings.#pragma once#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "EncryptClass.generated.h"/*** */
UCLASS()
class OPENTEST_API UEncryptClass : public UBlueprintFunctionLibrary
{GENERATED_BODY()
public:UFUNCTION(BlueprintCallable)static bool EncryptStringWithAES(const FString& InputString, const FString& EncryptionKey, FString& OutEncryptedString);};
// Fill out your copyright notice in the Description page of Project Settings.#include "EncryptClass.h"#define UI UI_ST
#include <openssl/ossl_typ.h>
#include <openssl/evp.h>
#undef UIbool UEncryptClass::EncryptStringWithAES(const FString& InputString, const FString& EncryptionKey, FString& OutEncryptedString)
{const unsigned char* iv = (const unsigned char*)"0123456789012345"; // 初始化向量(IV),需要与解密时一致int keylength = 128; // 加密密钥长度,可以是128、192或256EVP_CIPHER_CTX* ctx;ctx = EVP_CIPHER_CTX_new();EVP_CIPHER_CTX_init(ctx);const EVP_CIPHER* cipherType = EVP_aes_128_cbc(); // 选择加密算法if (EVP_EncryptInit_ex(ctx, cipherType, NULL, (const unsigned char*)TCHAR_TO_UTF8(*EncryptionKey), iv) != 1) {// 初始化加密上下文失败return false;}int max_output_length = InputString.Len() + EVP_MAX_BLOCK_LENGTH; // 预估加密后的最大长度unsigned char* encryptedOutput = new unsigned char[max_output_length];int encryptedLength = 0;if (EVP_EncryptUpdate(ctx, encryptedOutput, &encryptedLength, (const unsigned char*)TCHAR_TO_UTF8(*InputString), InputString.Len()) != 1) {// 加密数据失败EVP_CIPHER_CTX_free(ctx);delete[] encryptedOutput;return false;}int finalEncryptedLength = 0;if (EVP_EncryptFinal_ex(ctx, encryptedOutput + encryptedLength, &finalEncryptedLength) != 1) {// 完成加密失败EVP_CIPHER_CTX_free(ctx);delete[] encryptedOutput;return false;}encryptedLength += finalEncryptedLength;// Convert encrypted data to hex stringFString HexString;for (int i = 0; i < encryptedLength; ++i) {FString Hex = FString::Printf(TEXT("%02x"), encryptedOutput[i]);HexString += Hex;}OutEncryptedString = HexString;EVP_CIPHER_CTX_free(ctx);delete[] encryptedOutput;return true;
}
4、解密
// Fill out your copyright notice in the Description page of Project Settings.#pragma once#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "DecryptClass.generated.h"/*** */
UCLASS()
class OPENTEST_API UDecryptClass : public UBlueprintFunctionLibrary
{GENERATED_BODY()public:UFUNCTION(BlueprintCallable)static bool DecryptStringWithAES(const FString& EncryptedString, const FString& EncryptionKey, FString& OutDecryptedString);
};
#include "DecryptClass.h"#define UI UI_ST
#include <openssl/ossl_typ.h>
#include <openssl/evp.h>
#undef UIbool UMynewJMClass::DecryptStringWithAES(const FString& EncryptedString, const FString& EncryptionKey,FString& OutDecryptedString)
{const unsigned char* iv = (const unsigned char*)"0123456789012345"; // IV, 与加密时一致int keylength = 128; // 密钥长度,与加密时一致EVP_CIPHER_CTX* ctx;ctx = EVP_CIPHER_CTX_new();EVP_CIPHER_CTX_init(ctx);const EVP_CIPHER* cipherType = EVP_aes_128_cbc(); // 选择加密算法if (EVP_DecryptInit_ex(ctx, cipherType, NULL, (const unsigned char*)TCHAR_TO_UTF8(*EncryptionKey), iv) != 1) {// 初始化解密上下文失败return false;}int max_output_length = EncryptedString.Len() / 2; // 预估解密后的最大长度unsigned char* decryptedOutput = new unsigned char[max_output_length];int decryptedLength = 0;// 将十六进制字符串转换回原始加密数据TArray<uint8> EncryptedData;for (int i = 0; i < EncryptedString.Len(); i += 2) {FString ByteString = EncryptedString.Mid(i, 2);uint8 Byte = (uint8)FCString::Strtoi64(*ByteString, nullptr, 16);EncryptedData.Add(Byte);}if (EVP_DecryptUpdate(ctx, decryptedOutput, &decryptedLength, EncryptedData.GetData(), EncryptedData.Num()) != 1) {// 解密数据失败EVP_CIPHER_CTX_free(ctx);delete[] decryptedOutput;return false;}int finalDecryptedLength = 0;if (EVP_DecryptFinal_ex(ctx, decryptedOutput + decryptedLength, &finalDecryptedLength) != 1) {// 完成解密失败EVP_CIPHER_CTX_free(ctx);delete[] decryptedOutput;return false;}decryptedLength += finalDecryptedLength;// 将解密后的内容存储在 OutDecryptedData 中TArray<uint8> DecryptedData;DecryptedData.SetNumUninitialized(decryptedLength);FMemory::Memcpy(DecryptedData.GetData(), decryptedOutput, decryptedLength);// Convert the bytes to a hex stringFString HexString;for (uint8 Byte : DecryptedData) {FString Hex = FString::Printf(TEXT("%02x"), Byte); // Convert byte to two-digit hex representationHexString += Hex;}OutDecryptedString = HexString;EVP_CIPHER_CTX_free(ctx);delete[] decryptedOutput;return true;
}
5、注册
// Fill out your copyright notice in the Description page of Project Settings.#pragma once#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "HexClass.generated.h"/*** */
UCLASS()
class OPENTEST_API UHexClass : public UBlueprintFunctionLibrary
{GENERATED_BODY()
public:UFUNCTION(BlueprintCallable)static FString HexStringToPlainText(const FString& HexString);};
// Fill out your copyright notice in the Description page of Project Settings.#include "HexClass.h"#include "GenericPlatform/GenericPlatformMisc.h"
#include "Misc/Guid.h"FString UHexClass::HexStringToPlainText(const FString& HexString)
{FString PlainText;// 将十六进制字符串转换为原始文本for (int i = 0; i < HexString.Len(); i += 2){FString ByteString = HexString.Mid(i, 2);int32 ByteValue = FCString::Strtoi(*ByteString, nullptr, 16);PlainText.AppendChar((TCHAR)ByteValue);}return PlainText;
}FString UMyhuanyuanClass::GetMachineId()
{return FPlatformMisc::GetMachineId().ToString();
}TArray<uint8> UMyhuanyuanClass::GetAllMacAddress()
{return FPlatformMisc::GetMacAddress();
}
相关文章:
UE5中一机一码功能
创建蓝图函数库 1、获取第一个有效的硬盘ID // Fill out your copyright notice in the Description page of Project Settings.#pragma once#include "CoreMinimal.h" #include "Kismet/BlueprintFunctionLibrary.h" #include "GetDiskIDClass.gen…...
gpt支持json格式的数据返回(response_format: ‘json_object‘)
Api.h5.chatCreateChatCompletion({model: gpt-3.5-turbo-1106,token: sk-f4fe8b67-fcbe-46fd-8cc9-fd1dac5d6d59,messages: [{role: user,content:使用json格式返回十二生肖,包含中文名和英文名,[{id:"1", enName:"", cnName: &quo…...
MySQL(13):约束
约束(constraint)概述 数据完整性(Data Integrity)是指数据的精确性(Accuracy)和可靠性(Reliability)。 它是防止数据库中存在不符合语义规定的数据和防止因错误信息的输入输出造成无效操作或错误信息 而提…...
可以为一个servlet定义多个servlet-mapping、或url-pattern
在web描述符文件web.xml文件中,可以为同一个servlet定义多个servlet-mapping;也可以在同一个servlet-mapping中,定义多个url-pattern。也就是说,可以把多个地址(相对于上下文路径)映射到同一个servlet处理。…...
.net在使用存储过程中IN参数的拼接方案,使用Join()方法
有时候拼接SQL语句时,可能会需要将list中的元素都加上单引号,并以逗号分开,但是Join只能简单的分开,没有有单引号! 1.第一种拼接方案 List<string> arrIds new List<string>(); arrIds.Add("aa&qu…...
基于RK3399的室内健身魔镜方案
I 方案背景 一、健身魔镜的兴起 2020年疫情席卷全球,宅家是防疫的措施之一,因而宅家运动火爆,随之而来的宅家运动器材也风靡起来,其中包含既有颜值又具有多种功能的健身魔镜。 Ⅱ 方案介绍 一、健身魔镜的方案介绍 …...
leetCode 25.K 个一组翻转链表
给你链表的头节点 head ,每 k 个节点一组进行翻转,请你返回修改后的链表。k 是一个正整数,它的值小于 或 等于链表的长度。如果节点总数不是 k 的整数倍,那么请将最后剩余的节点保持原有顺序。你不能只是单纯的改变节点内部的值&a…...
ElasticSearch中常见的分词器介绍
文章目录 ElasticSearch中常见的分词器介绍前言分词器的作用如何指定分词器分词器的组成分词器的类型标准分词器空格分词器简单分词器关键词分词器停用词分词器IK分词器NGram分词器正则匹配分词器语言分词器自定义分词器 ElasticSearch中常见的分词器介绍 前言 ElasticSearch是…...
前端案例-css实现ul中对li进行换行
场景描述: 我想要实现,在展示的item个数少于4个的时候,则排成一行,并且均分(比如说有3个,则每个的宽度为33.3%),如果item 个数大于4,则进行换行。 效果如下:…...
【Unity】 场景优化策略
Unity 场景优化策略 GPU instancing 使用GPU Instancing可以将多个网格相同、材质相同、材质属性可以不同的物体合并为一个批次,从而减少Draw Calls的次数。这可以提高性能和渲染效率。 GPU instancing可用于绘制在场景中多次出现的几何体,例如树木或…...
JavaWeb Day09 Mybatis-基础操作01-增删改查
目录 环境准备 ①Emp.sql ②Emp.java 一、删除 ①Mapper层 ②测试类 ③预编译SQL(查看mybatis日志) 1.性能 2.安全 ④总结 二、新增 ①Mapper层 ②测试类 ③结果 ④新增(主键返回) 1.Mapper层 2.测试类 ⑤总结…...
2.前端调试(控制台使用)
消息堆叠 如果一条消息连续重复,而不是在新行上输出每一个消息实例,控制台将“堆叠”消息并在左侧外边距显示一个数字。此数字表示该消息已重复的次数。 如果您倾向于为每一个日志使用一个独特的行条目,请在 DevTools 设置中启用 Show times…...
Jenkins简介及Docker Compose部署
Jenkins是一个开源的自动化服务器,用于自动化构建、测试和部署软件项目。它提供了丰富的插件生态系统,支持各种编程语言和工具,使得软件开发流程更加高效和可靠。在本文中,我们将介绍Jenkins的基本概念,并展示如何使用…...
sqli-labs关卡14(基于post提交的双引号闭合的报错注入)通关思路
文章目录 前言一、回顾上一关知识点二、靶场第十四关通关思路1、判断注入点2、爆显位3、爆数据库名4、爆数据库表5、爆数据库列6、爆数据库关键信息 总结 前言 此文章只用于学习和反思巩固sql注入知识,禁止用于做非法攻击。注意靶场是可以练习的平台,不…...
【广州华锐互动】楼宇智能化VR虚拟教学系统
在如今的技术时代,教育行业正在逐步引入各种创新方法以提升教学质量。VR公司广州华锐互动开发的楼宇智能化VR虚拟教学系统就是其中的一种,它利用虚拟现实(VR)技术,为学生提供一种全新的、沉浸式的学习体验。 楼宇智能化VR虚拟教学系统涵盖综合…...
5. HTML常用标签
5.1 标签语义 学习标签是有技巧的,重点是记住每个标签的语义。简单理解就是指标签的含义。即这个标签是用来干嘛的。 根据标签的语义,在合适的地方给一个最为合理的标签。可以让页面结构给清晰。 5.2 标题标签 <h1>-<h6>(重要) HTML提供了…...
傅里叶分析(2)
在《傅里叶分析(1)》中,讲述了连续信号的傅里叶分析方法,本文讲述离散信号的傅里叶分析方法。 虽然电、声、光、机械振动等信号在物理上是连续函数,但在实际工程中,其通常为离散信号,即若干离散…...
Mysql8数据库如何给用户授权
转载自:https://blog.csdn.net/Numb_ZL/article/details/124222795 查看用户已有权限 SHOW GRANTS FOR [用户名];使用root用户授予所有权限 -- 授权 GRANT ALL PRIVILEGES ON [数据库名].[表明] TO [用户名][连接主机ip地址] WITH GRANT OPTION; -- 刷新权限 FLU…...
reticulate | R-python调用 | 安装及配置 | conda文件配置
reticulate | R-python安装及配置 | conda文件配置 1. 基础知识2. 安装reticulate from CRAN3. 包含了用于Python和R之间协同操作的全套工具,在R和Rstudio中均可使用4. 配置python环境4.1 4种环境配置方式4.2 miniconda 环境install_miniconda()报错一install_minic…...
VueRequest——管理请求状态库
文章目录 前言一、为什么选择 VueRequest?二、使用步骤1.安装2.用例 前言 VueRequest——开发文档 VueReques——GitHub地址 在以往的业务项目中,我们经常会被 loading 状态的管理、请求的节流防抖、接口数据的缓存、分页等重复的功能实现所困扰。每次开…...
Spring数据访问模块设计
前面我们已经完成了IoC和web模块的设计,聪明的码友立马就知道了,该到数据访问模块了,要不就这俩玩个6啊,查库势在必行,至此,它来了。 一、核心设计理念 1、痛点在哪 应用离不开数据(数据库、No…...
初探Service服务发现机制
1.Service简介 Service是将运行在一组Pod上的应用程序发布为网络服务的抽象方法。 主要功能:服务发现和负载均衡。 Service类型的包括ClusterIP类型、NodePort类型、LoadBalancer类型、ExternalName类型 2.Endpoints简介 Endpoints是一种Kubernetes资源…...
MFC 抛体运动模拟:常见问题解决与界面美化
在 MFC 中开发抛体运动模拟程序时,我们常遇到 轨迹残留、无效刷新、视觉单调、物理逻辑瑕疵 等问题。本文将针对这些痛点,详细解析原因并提供解决方案,同时兼顾界面美化,让模拟效果更专业、更高效。 问题一:历史轨迹与小球残影残留 现象 小球运动后,历史位置的 “残影”…...
基于Springboot+Vue的办公管理系统
角色: 管理员、员工 技术: 后端: SpringBoot, Vue2, MySQL, Mybatis-Plus 前端: Vue2, Element-UI, Axios, Echarts, Vue-Router 核心功能: 该办公管理系统是一个综合性的企业内部管理平台,旨在提升企业运营效率和员工管理水…...
云原生安全实战:API网关Envoy的鉴权与限流详解
🔥「炎码工坊」技术弹药已装填! 点击关注 → 解锁工业级干货【工具实测|项目避坑|源码燃烧指南】 一、基础概念 1. API网关 作为微服务架构的统一入口,负责路由转发、安全控制、流量管理等核心功能。 2. Envoy 由Lyft开源的高性能云原生…...
深入解析光敏传感技术:嵌入式仿真平台如何重塑电子工程教学
一、光敏传感技术的物理本质与系统级实现挑战 光敏电阻作为经典的光电传感器件,其工作原理根植于半导体材料的光电导效应。当入射光子能量超过材料带隙宽度时,价带电子受激发跃迁至导带,形成电子-空穴对,导致材料电导率显著提升。…...
欢乐熊大话蓝牙知识17:多连接 BLE 怎么设计服务不会乱?分层思维来救场!
多连接 BLE 怎么设计服务不会乱?分层思维来救场! 作者按: 你是不是也遇到过 BLE 多连接时,调试现场像网吧“掉线风暴”? 温度传感器连上了,心率带丢了;一边 OTA 更新,一边通知卡壳。…...
C#最佳实践:为何优先使用as或is而非强制转换
C#最佳实践:为何优先使用as或is而非强制转换 在 C# 的编程世界里,类型转换是我们经常会遇到的操作。就像在现实生活中,我们可能需要把不同形状的物品重新整理归类一样,在代码里,我们也常常需要将一个数据类型转换为另…...
PLC入门【4】基本指令2(SET RST)
04 基本指令2 PLC编程第四课基本指令(2) 1、运用上接课所学的基本指令完成个简单的实例编程。 2、学习SET--置位指令 3、RST--复位指令 打开软件(FX-TRN-BEG-C),从 文件 - 主画面,“B: 让我们学习基本的”- “B-3.控制优先程序”。 点击“梯形图编辑”…...
本地部署drawDB结合内网穿透技术实现数据库远程管控方案
文章目录 前言1. Windows本地部署DrawDB2. 安装Cpolar内网穿透3. 实现公网访问DrawDB4. 固定DrawDB公网地址 前言 在数字化浪潮席卷全球的背景下,数据治理能力正日益成为构建现代企业核心竞争力的关键因素。无论是全球500强企业的数据中枢系统,还是初创…...
