Unity3D内容加密保护
仅管资源 (Assets) 在传输时可使用加密进行保护,但在数据流入客户手中后。其内容就有可能被获取。比如,有工具可记录驱动程序级别上的 3D 数据,同意用户提取传送至 GPU 的模型和纹理。
因此,我们通常希望在用户决定提取资源时。可以满足其要求。
当然,假设您须要。也能够对资源包 (AssetBundle) 文件使用自己的数据加密。
一种方法是,使用文本资源 (AssetBundle) 类型将数据存储为字节。您能够加密数据文件,并使用扩展名 .bytes 进行保存,Unity 会将其视为文本资源 (TextAsset) 类型。在编辑器 ( Editor) 中导入后。作为文本资源 (TextAssets) 的文件可导入将置于server上的资源包 (AssetBundle)。客户能够下载资源包 (AssetBundle) 并将存储在文本资源 (TextAsset) 中的字节解密为内容。借助此方法。既不会对资源包
(AssetBundles) 加密,又能够将数据作为文本资源 (TextAssets) 保存。
string url = "http://www.mywebsite.com/mygame/assetbundles/assetbundle1.unity3d";
IEnumerator Start () {
// Start a download of the encrypted assetbundle
WWW www = new WWW.LoadFromCacheOrDownload (url, 1); // Wait for download to complete
yield return www; // Load the TextAsset from the AssetBundle
TextAsset textAsset = www.assetBundle.Load("EncryptedData", typeof(TextAsset)); // Get the byte data
byte[] encryptedData = textAsset.bytes; // Decrypt the AssetBundle data
byte[] decryptedData = YourDecryptionMethod(encryptedData); // Use your byte array.The AssetBundle will be cached
}
还有一可用方法是对资源中的资源包 (AssetBundles) 全然加密。然后使用 WWW 类下载资源包。仅仅要server将其作为二进制数据提供 ,则可用不论什么您喜欢的文件扩展名命名。
下载完毕后。您能够使用 WWW 实例的 .bytes 属性数据相关的解密程序获取解密的资源包 (AssetBundle) 文件数据。并使用
AssetBundle.CreateFromMemory 在内存中创建资源包 (AssetBundle)。
string url = "http://www.mywebsite.com/mygame/assetbundles/assetbundle1.unity3d";
IEnumerator Start () {
// Start a download of the encrypted assetbundle
WWW www = new WWW (url); // Wait for download to complete
yield return www; // Get the byte data
byte[] encryptedData = www.bytes; // Decrypt the AssetBundle data
byte[] decryptedData = YourDecryptionMethod(encryptedData); // Create an AssetBundle from the bytes array
AssetBundle bundle = AssetBundle.CreateFromMemory(decryptedData); // You can now use your AssetBundle.The AssetBundle is not cached.
}
另外一种方法之于第一种方法的优势在于。可使用不论什么类函数(AssetBundles.LoadFromCacheOrDownload 除外)传输字节,而且可对数据进行全然加密 – 比如。插件中的套接字。
缺点在于无法使用 Unity 的自己主动缓存功能进行缓存。
可使用全部播放器(网页播放器 (WebPlayer) 除外)在磁盘上手动存储文件,并使用
AssetBundles.CreateFromFile 载入文件。
第三种方法结合了前两种方法的长处,可将资源包 (AssetBundle) 另存为其它普通资源包中的文本资源 (TextAsset)。系统会缓存包括已加密资源包 (AssetBundle) 的未加密资源包。然后会将原始资源包 (AssetBundle) 载入到内存。并使用
AssetBundle.CreateFromMemory 解密并实例化。
string url = "http://www.mywebsite.com/mygame/assetbundles/assetbundle1.unity3d";
IEnumerator Start () {
// Start a download of the encrypted assetbundle
WWW www = new WWW.LoadFromCacheOrDownload (url, 1); // Wait for download to complete
yield return www; // Load the TextAsset from the AssetBundle
TextAsset textAsset = www.assetBundle.Load("EncryptedData", typeof(TextAsset)); // Get the byte data
byte[] encryptedData = textAsset.bytes; // Decrypt the AssetBundle data
byte[] decryptedData = YourDecryptionMethod(encryptedData); // Create an AssetBundle from the bytes array
AssetBundle bundle = AssetBundle.CreateFromMemory(decryptedData); // You can now use your AssetBundle.The wrapper AssetBundle is cached
}
Unity3D内容加密保护的更多相关文章
- Unity3D 代码加密保护工具
加密方式 对于Unity3D的保护方式,主要是通过Virbox Protector Standalone对Unity3D程序的整个生成目录进行加密,可以保护Unity的主要代码逻辑不被反编译,最大 ...
- .NET 产品版权保护方案 (.NET源码加密保护) (转载)
说 明:你希望自己用.net辛辛苦苦做出来的软件被人轻易破解吗?你希望自己花了大量人力物力用.net开发出来的产品被竞争对手轻易获取核心代码吗?这是 一篇比较详尽地介绍如何保护自己的.net源代码的文 ...
- C#/vbscript/JS如何加密保护HTML/javascript源代码
原文地址:http://www.coding123.net/article/20121008/encrypt-javascript-by-charp-vbscript.aspx 本文通过将源代码进行u ...
- [破解] DRM-内容数据版权加密保护技术学习(上):视频文件打包实现
1. DRM介绍: DRM,英文全称Digital Rights Management, 可以翻译为:内容数字版权加密保护技术. DRM技术的工作原理是,首先建立数字节目授权中心.编码压缩后的数字节目 ...
- [C#防止反编译].NET 产品版权保护方案 (.NET源码加密保护)
[C#防止反编译].NET 产品版权保护方案 (.NET源码加密保护) 标签: .net加密产品c#dll工具 2011-03-24 21:06 27009人阅读 评论(13) 收藏 举报 分类: C ...
- SpringBoot自定义classloader加密保护class文件
背景 最近针对公司框架进行关键业务代码进行加密处理,防止通过jd-gui等反编译工具能够轻松还原工程代码,相关混淆方案配置使用比较复杂且针对springboot项目问题较多,所以针对class文件加密 ...
- .Net加密保护工具分析介绍
本文主要介绍一些dotNet加密保护工具的原理以及就其脱壳进行简单探讨. remotesoft protector.maxtocode..Net Reactor.Cliprotector.themid ...
- NET Framework 4.5新特性 数据库的连接加密保护。
NET Framework 4.5新特性 (一) 数据库的连接加密保护. NET Framework 4.5 ado.net数据库连接支持使用SecureString内存流方式保密文本. 一旦使用这 ...
- 在IOS中使用DES算法对Sqlite数据库进行内容加密存储并读取解密
在IOS中使用DES算法对Sqlite 数据库进行内容加密存储并读取解密 涉及知识点: 1.DES加密算法: 2.OC对Sqlite数据库的读写: 3.IOS APP文件存储的两种方式及读取方式. 以 ...
随机推荐
- Android网络开发之WIFI
WIFI全称Wireless Fidelity, 又称802.11b标准.WIFI联盟成立于1999年,当时的名称叫做Wireless Ethernet Compatibility Alliance( ...
- tomcat占用cpu过高解决办法
在工作中经常遇到tomcat占用cpu居高不下,针对这种情况有以下处理办法进行排查. jps --> 查看java的进程 top -Hp pid --> 根据jps得到的进程号(pid), ...
- Python 多进程教程
Python2.6版本中新添了multiprocessing模块.它最初由Jesse Noller和Richard Oudkerk定义在PEP 371中.就像你能通过threading模块衍生线程一样 ...
- Numpy库应用实例——GPS定位
背景介绍 定位系统 GPS全球定位系统(Global Positioning System)以GPS系统为例介绍卫星定位的计算方法 GPS定位的基本原理 GPS定位的基本原理是根据高速运动卫星的 ...
- JavaScript:用JS实现加载页面前弹出模态框
用JS实现加载页面前弹出模态框 主要的JavaScript 代码是: <script> //加载模态框 $('#myModal').modal(); $(document).ready(f ...
- Linux命令-进程查看命令:ps
查看进行 ps aux
- 【jQuery】页面顶部显示的进度条效果
<!Doctype html> <html> <head> <title>页面顶部显示的进度条效果</title> <meta htt ...
- android 布局权重问题(最近布局经常坑爹)
android 布局 权重 With layout_weight you can specify a size ratio between multiple views. E.g. you have ...
- SIPp常用脚本之三:UAC
UAC是作为SIP消息的发起端,可以控制消息速率什么的,方便极了. 一.uac.xml <?xml version="1.0" encoding="ISO-8859 ...
- window 环境 Composer 安装 thinkphp5
参考链接:https://www.kancloud.cn/thinkphp/thinkphp5_quickstart/478269 在 Windows 中,你需要下载并运行 Composer-Setu ...