Skip to content

Commit 35befd6

Browse files
committed
updated to v2.12.2
1 parent 6abeb38 commit 35befd6

21 files changed

Lines changed: 620 additions & 246 deletions

Assets/OxGFrame/AssetLoader/Scripts/Editor/Bundle/YooAssets/EncryptionServices.cs

Lines changed: 82 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using OxGFrame.AssetLoader.Bundle;
2-
using System.IO;
32
using UnityEngine;
43
using YooAsset;
54

@@ -16,16 +15,29 @@ public static CryptogramSetting GetCryptogramSetting()
1615
}
1716
}
1817

19-
public class OffSetEncryption : IEncryptionServices
18+
public class OffsetEncryption : IEncryptionServices
2019
{
20+
private int? _randomSeed = null;
21+
private int? _dummySize = null;
22+
23+
public OffsetEncryption()
24+
{
25+
}
26+
27+
public OffsetEncryption(int randomSeed, int dummySize)
28+
{
29+
this._randomSeed = randomSeed;
30+
this._dummySize = dummySize;
31+
}
32+
2133
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
2234
{
2335
var cryptogramSettings = CryptogramSettingSetup.GetCryptogramSetting();
2436

2537
string filePath = fileInfo.FilePath;
2638

27-
int randomSeed = cryptogramSettings.randomSeed;
28-
int dummySize = cryptogramSettings.dummySize;
39+
int randomSeed = this._randomSeed == null ? cryptogramSettings.randomSeed : (int)this._randomSeed;
40+
int dummySize = this._dummySize == null ? cryptogramSettings.dummySize : (int)this._dummySize;
2941

3042
byte[] fileData = FileCryptogram.Offset.OffsetEncryptBytes(filePath, randomSeed, dummySize);
3143

@@ -49,13 +61,24 @@ public EncryptResult Encrypt(EncryptFileInfo fileInfo)
4961

5062
public class XorEncryption : IEncryptionServices
5163
{
64+
private byte? _xorKey = null;
65+
66+
public XorEncryption()
67+
{
68+
}
69+
70+
public XorEncryption(byte xorKey)
71+
{
72+
this._xorKey = xorKey;
73+
}
74+
5275
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
5376
{
5477
var cryptogramSettings = CryptogramSettingSetup.GetCryptogramSetting();
5578

5679
string filePath = fileInfo.FilePath;
5780

58-
byte xorKey = cryptogramSettings.xorKey;
81+
byte xorKey = this._xorKey == null ? cryptogramSettings.xorKey : (byte)this._xorKey;
5982

6083
byte[] fileData = FileCryptogram.XOR.XorEncryptBytes(filePath, xorKey);
6184

@@ -79,15 +102,30 @@ public EncryptResult Encrypt(EncryptFileInfo fileInfo)
79102

80103
public class HT2XorEncryption : IEncryptionServices
81104
{
105+
private byte? _hXorKey = null;
106+
private byte? _tXorKey = null;
107+
private byte? _jXorKey = null;
108+
109+
public HT2XorEncryption()
110+
{
111+
}
112+
113+
public HT2XorEncryption(byte hXorKey, byte tXorKey, byte jXorKey)
114+
{
115+
this._hXorKey = hXorKey;
116+
this._tXorKey = tXorKey;
117+
this._jXorKey = jXorKey;
118+
}
119+
82120
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
83121
{
84122
var cryptogramSettings = CryptogramSettingSetup.GetCryptogramSetting();
85123

86124
string filePath = fileInfo.FilePath;
87125

88-
byte hXorKey = cryptogramSettings.hXorKey;
89-
byte tXorKey = cryptogramSettings.tXorKey;
90-
byte jXorKey = cryptogramSettings.jXorKey;
126+
byte hXorKey = this._hXorKey == null ? cryptogramSettings.hXorKey : (byte)this._hXorKey;
127+
byte tXorKey = this._tXorKey == null ? cryptogramSettings.tXorKey : (byte)this._tXorKey;
128+
byte jXorKey = this._jXorKey == null ? cryptogramSettings.jXorKey : (byte)this._jXorKey;
91129

92130
byte[] fileData = FileCryptogram.HT2XOR.HT2XorEncryptBytes(filePath, hXorKey, tXorKey, jXorKey);
93131

@@ -111,16 +149,33 @@ public EncryptResult Encrypt(EncryptFileInfo fileInfo)
111149

112150
public class HT2XorPlusEncryption : IEncryptionServices
113151
{
152+
private byte? _hXorKey = null;
153+
private byte? _tXorKey = null;
154+
private byte? _j1XorKey = null;
155+
private byte? _j2XorKey = null;
156+
157+
public HT2XorPlusEncryption()
158+
{
159+
}
160+
161+
public HT2XorPlusEncryption(byte hXorKey, byte tXorKey, byte j1XorKey, byte j2XorKey)
162+
{
163+
this._hXorKey = hXorKey;
164+
this._tXorKey = tXorKey;
165+
this._j1XorKey = j1XorKey;
166+
this._j2XorKey = j2XorKey;
167+
}
168+
114169
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
115170
{
116171
var cryptogramSettings = CryptogramSettingSetup.GetCryptogramSetting();
117172

118173
string filePath = fileInfo.FilePath;
119174

120-
byte hXorKey = cryptogramSettings.hXorPlusKey;
121-
byte tXorKey = cryptogramSettings.tXorPlusKey;
122-
byte j1XorKey = cryptogramSettings.j1XorPlusKey;
123-
byte j2XorKey = cryptogramSettings.j2XorPlusKey;
175+
byte hXorKey = this._hXorKey == null ? cryptogramSettings.hXorPlusKey : (byte)this._hXorKey;
176+
byte tXorKey = this._tXorKey == null ? cryptogramSettings.tXorPlusKey : (byte)this._tXorKey;
177+
byte j1XorKey = this._j1XorKey == null ? cryptogramSettings.j1XorPlusKey : (byte)this._j1XorKey;
178+
byte j2XorKey = this._j2XorKey == null ? cryptogramSettings.j2XorPlusKey : (byte)this._j2XorKey;
124179

125180
byte[] fileData = FileCryptogram.HT2XORPlus.HT2XorPlusEncryptBytes(filePath, hXorKey, tXorKey, j1XorKey, j2XorKey);
126181

@@ -144,14 +199,27 @@ public EncryptResult Encrypt(EncryptFileInfo fileInfo)
144199

145200
public class AesEncryption : IEncryptionServices
146201
{
202+
private string _aesKey = null;
203+
private string _aesIv = null;
204+
205+
public AesEncryption()
206+
{
207+
}
208+
209+
public AesEncryption(string aesKey, string aesIv)
210+
{
211+
this._aesKey = aesKey;
212+
this._aesIv = aesIv;
213+
}
214+
147215
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
148216
{
149217
var cryptogramSettings = CryptogramSettingSetup.GetCryptogramSetting();
150218

151219
string filePath = fileInfo.FilePath;
152220

153-
string aesKey = cryptogramSettings.aesKey;
154-
string aesIv = cryptogramSettings.aesIv;
221+
string aesKey = string.IsNullOrEmpty(this._aesKey) ? cryptogramSettings.aesKey : this._aesKey;
222+
string aesIv = string.IsNullOrEmpty(this._aesIv) ? cryptogramSettings.aesIv : this._aesIv;
155223

156224
byte[] fileData = FileCryptogram.AES.AesEncryptBytes(filePath, aesKey, aesIv);
157225

Assets/OxGFrame/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## [2.12.2] - 2024-11-11
4+
- Updated UniEvent of UniFramework.
5+
- Added constructors in EncryptionServices (Editor).
6+
37
## [2.12.1] - 2024-11-08
48
- Added MediaFrame (Audio, Video) with an option to specify a sourceClip, handled by the prefab container for playback.
59
```csharp

Assets/OxGFrame/ThirdParty/UniFramework/UniEvent/Runtime/EventGroup.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Collections;
32
using System.Collections.Generic;
43

54
namespace UniFramework.Event
@@ -13,7 +12,7 @@ public EventGroup() { }
1312

1413
public EventGroup(int groupId)
1514
{
16-
this._groupId = groupId;
15+
_groupId = groupId;
1716
}
1817

1918
/// <summary>
@@ -28,8 +27,10 @@ public void AddListener<TEvent>(System.Action<IEventMessage> listener) where TEv
2827
if (_cachedListener[eventType].Contains(listener) == false)
2928
{
3029
_cachedListener[eventType].Add(listener);
31-
if (this._groupId != null) UniEvent.AddListener((int)this._groupId, listener);
32-
else UniEvent.AddListener(eventType, listener);
30+
if (_groupId != null)
31+
UniEvent.AddListener((int)_groupId, listener);
32+
else
33+
UniEvent.AddListener(eventType, listener);
3334
}
3435
else
3536
{
@@ -47,8 +48,10 @@ public void RemoveAllListener()
4748
System.Type eventType = pair.Key;
4849
for (int i = 0; i < pair.Value.Count; i++)
4950
{
50-
if (this._groupId != null) UniEvent.RemoveListener((int)this._groupId, pair.Value[i]);
51-
else UniEvent.RemoveListener(eventType, pair.Value[i]);
51+
if (_groupId != null)
52+
UniEvent.RemoveListener((int)_groupId, pair.Value[i]);
53+
else
54+
UniEvent.RemoveListener(eventType, pair.Value[i]);
5255
}
5356
pair.Value.Clear();
5457
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
namespace UniFramework.Event
33
{
4-
public interface IEventMessage
5-
{
6-
}
4+
public interface IEventMessage
5+
{
6+
}
77
}

0 commit comments

Comments
 (0)