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 状态的管理、请求的节流防抖、接口数据的缓存、分页等重复的功能实现所困扰。每次开…...
Linux简单的操作
ls ls 查看当前目录 ll 查看详细内容 ls -a 查看所有的内容 ls --help 查看方法文档 pwd pwd 查看当前路径 cd cd 转路径 cd .. 转上一级路径 cd 名 转换路径 …...

转转集团旗下首家二手多品类循环仓店“超级转转”开业
6月9日,国内领先的循环经济企业转转集团旗下首家二手多品类循环仓店“超级转转”正式开业。 转转集团创始人兼CEO黄炜、转转循环时尚发起人朱珠、转转集团COO兼红布林CEO胡伟琨、王府井集团副总裁祝捷等出席了开业剪彩仪式。 据「TMT星球」了解,“超级…...
linux 错误码总结
1,错误码的概念与作用 在Linux系统中,错误码是系统调用或库函数在执行失败时返回的特定数值,用于指示具体的错误类型。这些错误码通过全局变量errno来存储和传递,errno由操作系统维护,保存最近一次发生的错误信息。值得注意的是,errno的值在每次系统调用或函数调用失败时…...

Cloudflare 从 Nginx 到 Pingora:性能、效率与安全的全面升级
在互联网的快速发展中,高性能、高效率和高安全性的网络服务成为了各大互联网基础设施提供商的核心追求。Cloudflare 作为全球领先的互联网安全和基础设施公司,近期做出了一个重大技术决策:弃用长期使用的 Nginx,转而采用其内部开发…...
Matlab | matlab常用命令总结
常用命令 一、 基础操作与环境二、 矩阵与数组操作(核心)三、 绘图与可视化四、 编程与控制流五、 符号计算 (Symbolic Math Toolbox)六、 文件与数据 I/O七、 常用函数类别重要提示这是一份 MATLAB 常用命令和功能的总结,涵盖了基础操作、矩阵运算、绘图、编程和文件处理等…...

《基于Apache Flink的流处理》笔记
思维导图 1-3 章 4-7章 8-11 章 参考资料 源码: https://github.com/streaming-with-flink 博客 https://flink.apache.org/bloghttps://www.ververica.com/blog 聚会及会议 https://flink-forward.orghttps://www.meetup.com/topics/apache-flink https://n…...

什么是Ansible Jinja2
理解 Ansible Jinja2 模板 Ansible 是一款功能强大的开源自动化工具,可让您无缝地管理和配置系统。Ansible 的一大亮点是它使用 Jinja2 模板,允许您根据变量数据动态生成文件、配置设置和脚本。本文将向您介绍 Ansible 中的 Jinja2 模板,并通…...

使用 Streamlit 构建支持主流大模型与 Ollama 的轻量级统一平台
🎯 使用 Streamlit 构建支持主流大模型与 Ollama 的轻量级统一平台 📌 项目背景 随着大语言模型(LLM)的广泛应用,开发者常面临多个挑战: 各大模型(OpenAI、Claude、Gemini、Ollama)接口风格不统一;缺乏一个统一平台进行模型调用与测试;本地模型 Ollama 的集成与前…...

云原生玩法三问:构建自定义开发环境
云原生玩法三问:构建自定义开发环境 引言 临时运维一个古董项目,无文档,无环境,无交接人,俗称三无。 运行设备的环境老,本地环境版本高,ssh不过去。正好最近对 腾讯出品的云原生 cnb 感兴趣&…...
tomcat指定使用的jdk版本
说明 有时候需要对tomcat配置指定的jdk版本号,此时,我们可以通过以下方式进行配置 设置方式 找到tomcat的bin目录中的setclasspath.bat。如果是linux系统则是setclasspath.sh set JAVA_HOMEC:\Program Files\Java\jdk8 set JRE_HOMEC:\Program Files…...