仅管资源 (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内容加密保护的更多相关文章

  1. Unity3D 代码加密保护工具

    加密方式   对于Unity3D的保护方式,主要是通过Virbox Protector Standalone对Unity3D程序的整个生成目录进行加密,可以保护Unity的主要代码逻辑不被反编译,最大 ...

  2. .NET 产品版权保护方案 (.NET源码加密保护) (转载)

    说 明:你希望自己用.net辛辛苦苦做出来的软件被人轻易破解吗?你希望自己花了大量人力物力用.net开发出来的产品被竞争对手轻易获取核心代码吗?这是 一篇比较详尽地介绍如何保护自己的.net源代码的文 ...

  3. C#/vbscript/JS如何加密保护HTML/javascript源代码

    原文地址:http://www.coding123.net/article/20121008/encrypt-javascript-by-charp-vbscript.aspx 本文通过将源代码进行u ...

  4. [破解] DRM-内容数据版权加密保护技术学习(上):视频文件打包实现

    1. DRM介绍: DRM,英文全称Digital Rights Management, 可以翻译为:内容数字版权加密保护技术. DRM技术的工作原理是,首先建立数字节目授权中心.编码压缩后的数字节目 ...

  5. [C#防止反编译].NET 产品版权保护方案 (.NET源码加密保护)

    [C#防止反编译].NET 产品版权保护方案 (.NET源码加密保护) 标签: .net加密产品c#dll工具 2011-03-24 21:06 27009人阅读 评论(13) 收藏 举报 分类: C ...

  6. SpringBoot自定义classloader加密保护class文件

    背景 最近针对公司框架进行关键业务代码进行加密处理,防止通过jd-gui等反编译工具能够轻松还原工程代码,相关混淆方案配置使用比较复杂且针对springboot项目问题较多,所以针对class文件加密 ...

  7. .Net加密保护工具分析介绍

    本文主要介绍一些dotNet加密保护工具的原理以及就其脱壳进行简单探讨. remotesoft protector.maxtocode..Net Reactor.Cliprotector.themid ...

  8. NET Framework 4.5新特性 数据库的连接加密保护。

    NET Framework 4.5新特性 (一) 数据库的连接加密保护. NET Framework 4.5 ado.net数据库连接支持使用SecureString内存流方式保密文本.  一旦使用这 ...

  9. 在IOS中使用DES算法对Sqlite数据库进行内容加密存储并读取解密

    在IOS中使用DES算法对Sqlite 数据库进行内容加密存储并读取解密 涉及知识点: 1.DES加密算法: 2.OC对Sqlite数据库的读写: 3.IOS APP文件存储的两种方式及读取方式. 以 ...

随机推荐

  1. Linux RAID5+备份盘测试

    RAID5磁盘阵列组技术至少需要3块盘来做,加上1块备份盘(这块硬盘设备平时是闲置状态不用工作,一旦RAID磁盘阵列组中有硬盘出现故障后则会马上自动顶替上去),总共是需要向虚拟机中模拟4块硬盘设备. ...

  2. 在Ubuntu16.04 64bit上安装sublime text 3

    安装sublime text 3 根据官网上提供的安装说明 https://www.sublimetext.com/docs/3/linux_repositories.html  进行安装, 首先是 ...

  3. 【微信小程序】实现类似WEB端【返回顶部】功能

    1.原理:利用小程序自带的<scroll-view>组件,该组件的bindScroll和scroll-top方法.属性进行联合操作 2.效果图: 3.wxml: <scroll-vi ...

  4. XMLHttpRequest cannot load ...谷歌浏览器跨域问题

    HTML页面通过Ajax调用公网web服务时,浏览器请求发送成功,但是响应的 xhr.status==0,控制台报错如下 XMLHttpRequest cannot load http://ws.we ...

  5. 【mysql】Innodb三大特性之adaptive hash index

    1.Adaptive Hash Indexes 定义 If a table fits almost entirely in main memory, the fastest way to perfor ...

  6. JavaScript 设计模式之简介

    一.设计模式概念解读 设计模式(Design pattern)是一套被反复使用.多数人知晓的.经过分类编目的.无数实战代码设计经验的总结.使用设计模式是为了让系统代码可重用.可扩展.可解耦.更容易被人 ...

  7. 你的Android不好用,都是因为这几点原因

    Android早已是全球最大.用户最多的移动操作系统,不过它离全球最好用还差得很远. 大家随手就能举出些曾经历过的糟心体验,如手机卡顿!电量不禁用!广告弹窗老是出现!不过很少有人会追根寻底的去问为何如 ...

  8. OAF_OAF组件系列1 - Item Style汇总(概念)

    20150506 Created By BaoXinjian

  9. Spring boot处理OPTIONS请求

    一.现象从fetch说起,用fetch构造一个POST请求. fetch('http://127.0.0.1:8000/api/login', { method: "POST", ...

  10. MATLAB(2)——小波工具箱使用简介

    作者:桂. 时间:2017-02-19  21:47:27 链接:http://www.cnblogs.com/xingshansi/articles/6417638.html 前言 本文主要介绍MA ...