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

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格式返回十二生肖&#xff0c;包含中文名和英文名&#xff0c;[{id:"1", enName:"", cnName: &quo…...

MySQL(13):约束

约束(constraint)概述 数据完整性&#xff08;Data Integrity&#xff09;是指数据的精确性&#xff08;Accuracy&#xff09;和可靠性&#xff08;Reliability&#xff09;。 它是防止数据库中存在不符合语义规定的数据和防止因错误信息的输入输出造成无效操作或错误信息 而提…...

可以为一个servlet定义多个servlet-mapping、或url-pattern

在web描述符文件web.xml文件中&#xff0c;可以为同一个servlet定义多个servlet-mapping&#xff1b;也可以在同一个servlet-mapping中&#xff0c;定义多个url-pattern。也就是说&#xff0c;可以把多个地址&#xff08;相对于上下文路径&#xff09;映射到同一个servlet处理。…...

.net在使用存储过程中IN参数的拼接方案,使用Join()方法

有时候拼接SQL语句时&#xff0c;可能会需要将list中的元素都加上单引号&#xff0c;并以逗号分开&#xff0c;但是Join只能简单的分开&#xff0c;没有有单引号&#xff01; 1.第一种拼接方案 List<string> arrIds new List<string>(); arrIds.Add("aa&qu…...

基于RK3399的室内健身魔镜方案

I 方案背景 一、健身魔镜的兴起 2020年疫情席卷全球&#xff0c;宅家是防疫的措施之一&#xff0c;因而宅家运动火爆&#xff0c;随之而来的宅家运动器材也风靡起来&#xff0c;其中包含既有颜值又具有多种功能的健身魔镜。 Ⅱ 方案介绍 一、健身魔镜的方案介绍 …...

leetCode 25.K 个一组翻转链表

给你链表的头节点 head &#xff0c;每 k 个节点一组进行翻转&#xff0c;请你返回修改后的链表。k 是一个正整数&#xff0c;它的值小于 或 等于链表的长度。如果节点总数不是 k 的整数倍&#xff0c;那么请将最后剩余的节点保持原有顺序。你不能只是单纯的改变节点内部的值&a…...

ElasticSearch中常见的分词器介绍

文章目录 ElasticSearch中常见的分词器介绍前言分词器的作用如何指定分词器分词器的组成分词器的类型标准分词器空格分词器简单分词器关键词分词器停用词分词器IK分词器NGram分词器正则匹配分词器语言分词器自定义分词器 ElasticSearch中常见的分词器介绍 前言 ElasticSearch是…...

前端案例-css实现ul中对li进行换行

场景描述&#xff1a; 我想要实现&#xff0c;在展示的item个数少于4个的时候&#xff0c;则排成一行&#xff0c;并且均分&#xff08;比如说有3个&#xff0c;则每个的宽度为33.3%&#xff09;&#xff0c;如果item 个数大于4&#xff0c;则进行换行。 效果如下&#xff1a…...

【Unity】 场景优化策略

Unity 场景优化策略 GPU instancing 使用GPU Instancing可以将多个网格相同、材质相同、材质属性可以不同的物体合并为一个批次&#xff0c;从而减少Draw Calls的次数。这可以提高性能和渲染效率。 GPU instancing可用于绘制在场景中多次出现的几何体&#xff0c;例如树木或…...

JavaWeb Day09 Mybatis-基础操作01-增删改查

目录 环境准备 ①Emp.sql ②Emp.java 一、删除 ①Mapper层 ②测试类 ③预编译SQL&#xff08;查看mybatis日志&#xff09; 1.性能 2.安全 ④总结 二、新增 ①Mapper层 ②测试类 ③结果 ④新增&#xff08;主键返回&#xff09; 1.Mapper层 2.测试类 ⑤总结​…...

2.前端调试(控制台使用)

消息堆叠 如果一条消息连续重复&#xff0c;而不是在新行上输出每一个消息实例&#xff0c;控制台将“堆叠”消息并在左侧外边距显示一个数字。此数字表示该消息已重复的次数。 如果您倾向于为每一个日志使用一个独特的行条目&#xff0c;请在 DevTools 设置中启用 Show times…...

Jenkins简介及Docker Compose部署

Jenkins是一个开源的自动化服务器&#xff0c;用于自动化构建、测试和部署软件项目。它提供了丰富的插件生态系统&#xff0c;支持各种编程语言和工具&#xff0c;使得软件开发流程更加高效和可靠。在本文中&#xff0c;我们将介绍Jenkins的基本概念&#xff0c;并展示如何使用…...

sqli-labs关卡14(基于post提交的双引号闭合的报错注入)通关思路

文章目录 前言一、回顾上一关知识点二、靶场第十四关通关思路1、判断注入点2、爆显位3、爆数据库名4、爆数据库表5、爆数据库列6、爆数据库关键信息 总结 前言 此文章只用于学习和反思巩固sql注入知识&#xff0c;禁止用于做非法攻击。注意靶场是可以练习的平台&#xff0c;不…...

【广州华锐互动】楼宇智能化VR虚拟教学系统

在如今的技术时代&#xff0c;教育行业正在逐步引入各种创新方法以提升教学质量。VR公司广州华锐互动开发的楼宇智能化VR虚拟教学系统就是其中的一种&#xff0c;它利用虚拟现实(VR)技术&#xff0c;为学生提供一种全新的、沉浸式的学习体验。 楼宇智能化VR虚拟教学系统涵盖综合…...

5. HTML常用标签

5.1 标签语义 学习标签是有技巧的&#xff0c;重点是记住每个标签的语义。简单理解就是指标签的含义。即这个标签是用来干嘛的。 根据标签的语义&#xff0c;在合适的地方给一个最为合理的标签。可以让页面结构给清晰。 5.2 标题标签 <h1>-<h6>(重要) HTML提供了…...

傅里叶分析(2)

在《傅里叶分析&#xff08;1&#xff09;》中&#xff0c;讲述了连续信号的傅里叶分析方法&#xff0c;本文讲述离散信号的傅里叶分析方法。 虽然电、声、光、机械振动等信号在物理上是连续函数&#xff0c;但在实际工程中&#xff0c;其通常为离散信号&#xff0c;即若干离散…...

Mysql8数据库如何给用户授权

转载自&#xff1a;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之间协同操作的全套工具&#xff0c;在R和Rstudio中均可使用4. 配置python环境4.1 4种环境配置方式4.2 miniconda 环境install_miniconda()报错一install_minic…...

VueRequest——管理请求状态库

文章目录 前言一、为什么选择 VueRequest&#xff1f;二、使用步骤1.安装2.用例 前言 VueRequest——开发文档 VueReques——GitHub地址 在以往的业务项目中&#xff0c;我们经常会被 loading 状态的管理、请求的节流防抖、接口数据的缓存、分页等重复的功能实现所困扰。每次开…...

IDEA运行Tomcat出现乱码问题解决汇总

最近正值期末周&#xff0c;有很多同学在写期末Java web作业时&#xff0c;运行tomcat出现乱码问题&#xff0c;经过多次解决与研究&#xff0c;我做了如下整理&#xff1a; 原因&#xff1a; IDEA本身编码与tomcat的编码与Windows编码不同导致&#xff0c;Windows 系统控制台…...

eNSP-Cloud(实现本地电脑与eNSP内设备之间通信)

说明&#xff1a; 想象一下&#xff0c;你正在用eNSP搭建一个虚拟的网络世界&#xff0c;里面有虚拟的路由器、交换机、电脑&#xff08;PC&#xff09;等等。这些设备都在你的电脑里面“运行”&#xff0c;它们之间可以互相通信&#xff0c;就像一个封闭的小王国。 但是&#…...

【2025年】解决Burpsuite抓不到https包的问题

环境&#xff1a;windows11 burpsuite:2025.5 在抓取https网站时&#xff0c;burpsuite抓取不到https数据包&#xff0c;只显示&#xff1a; 解决该问题只需如下三个步骤&#xff1a; 1、浏览器中访问 http://burp 2、下载 CA certificate 证书 3、在设置--隐私与安全--…...

Python如何给视频添加音频和字幕

在Python中&#xff0c;给视频添加音频和字幕可以使用电影文件处理库MoviePy和字幕处理库Subtitles。下面将详细介绍如何使用这些库来实现视频的音频和字幕添加&#xff0c;包括必要的代码示例和详细解释。 环境准备 在开始之前&#xff0c;需要安装以下Python库&#xff1a;…...

浅谈不同二分算法的查找情况

二分算法原理比较简单&#xff0c;但是实际的算法模板却有很多&#xff0c;这一切都源于二分查找问题中的复杂情况和二分算法的边界处理&#xff0c;以下是博主对一些二分算法查找的情况分析。 需要说明的是&#xff0c;以下二分算法都是基于有序序列为升序有序的情况&#xf…...

LINUX 69 FTP 客服管理系统 man 5 /etc/vsftpd/vsftpd.conf

FTP 客服管理系统 实现kefu123登录&#xff0c;不允许匿名访问&#xff0c;kefu只能访问/data/kefu目录&#xff0c;不能查看其他目录 创建账号密码 useradd kefu echo 123|passwd -stdin kefu [rootcode caozx26420]# echo 123|passwd --stdin kefu 更改用户 kefu 的密码…...

【无标题】路径问题的革命性重构:基于二维拓扑收缩色动力学模型的零点隧穿理论

路径问题的革命性重构&#xff1a;基于二维拓扑收缩色动力学模型的零点隧穿理论 一、传统路径模型的根本缺陷 在经典正方形路径问题中&#xff08;图1&#xff09;&#xff1a; mermaid graph LR A((A)) --- B((B)) B --- C((C)) C --- D((D)) D --- A A -.- C[无直接路径] B -…...

TSN交换机正在重构工业网络,PROFINET和EtherCAT会被取代吗?

在工业自动化持续演进的今天&#xff0c;通信网络的角色正变得愈发关键。 2025年6月6日&#xff0c;为期三天的华南国际工业博览会在深圳国际会展中心&#xff08;宝安&#xff09;圆满落幕。作为国内工业通信领域的技术型企业&#xff0c;光路科技&#xff08;Fiberroad&…...

DBLP数据库是什么?

DBLP&#xff08;Digital Bibliography & Library Project&#xff09;Computer Science Bibliography是全球著名的计算机科学出版物的开放书目数据库。DBLP所收录的期刊和会议论文质量较高&#xff0c;数据库文献更新速度很快&#xff0c;很好地反映了国际计算机科学学术研…...

小木的算法日记-多叉树的递归/层序遍历

&#x1f332; 从二叉树到森林&#xff1a;一文彻底搞懂多叉树遍历的艺术 &#x1f680; 引言 你好&#xff0c;未来的算法大神&#xff01; 在数据结构的世界里&#xff0c;“树”无疑是最核心、最迷人的概念之一。我们中的大多数人都是从 二叉树 开始入门的&#xff0c;它…...