Skip to content

Commit 837d85b

Browse files
committed
updated to v3.2.0
1 parent a16a3f7 commit 837d85b

129 files changed

Lines changed: 5159 additions & 1045 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Assets/OxGFrame/AssetLoader/Scripts/Editor/Bundle/CryptogramSetting.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ namespace OxGFrame.AssetLoader.Editor
77
public class CryptogramSetting : ScriptableObject
88
{
99
[Separator("OFFSET")]
10-
public int randomSeed = 1;
1110
public int dummySize = 1;
1211

1312
[Separator("XOR")]
@@ -18,7 +17,7 @@ public class CryptogramSetting : ScriptableObject
1817
public byte tXorKey = 1;
1918
public byte jXorKey = 1;
2019

21-
[Separator("HT2XORPlus")]
20+
[Separator("HT2XOR Plus")]
2221
public byte hXorPlusKey = 1;
2322
public byte tXorPlusKey = 1;
2423
public byte j1XorPlusKey = 1;
@@ -27,5 +26,17 @@ public class CryptogramSetting : ScriptableObject
2726
[Separator("AES")]
2827
public string aesKey = "aes_key";
2928
public string aesIv = "aes_iv";
29+
30+
[Separator("CHACHA20")]
31+
public string chacha20Key = "chacha20_key";
32+
public string chacha20Nonce = "chacha20_nonce";
33+
public uint chacha20Counter = 1;
34+
35+
[Separator("XXTEA")]
36+
public string xxteaKey = "xxtea_key";
37+
38+
[Separator("OFFSET XOR")]
39+
public byte offsetXorKey = 1;
40+
public int offsetXorDummySize = 1;
3041
}
3142
}

Assets/OxGFrame/AssetLoader/Scripts/Editor/Bundle/EditorWindow/BundleCryptogramUtilityWindow.cs

Lines changed: 175 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ private void OnEnable()
5555
private void _LoadSettingsData()
5656
{
5757
// Offset
58-
this.randomSeed = this._setting.randomSeed;
5958
this.dummySize = this._setting.dummySize;
6059

6160
// XOR
@@ -75,6 +74,18 @@ private void _LoadSettingsData()
7574
// AES
7675
this.aesKey = this._setting.aesKey;
7776
this.aesIv = this._setting.aesIv;
77+
78+
// ChaCha20
79+
this.chacha20Key = this._setting.chacha20Key;
80+
this.chacha20Nonce = this._setting.chacha20Nonce;
81+
this.chacha20Counter = this._setting.chacha20Counter;
82+
83+
// XXTEA
84+
this.xxteaKey = this._setting.xxteaKey;
85+
86+
// OffsetXOR
87+
this.offsetXorKey = this._setting.offsetXorKey;
88+
this.offsetXorDummySize = this._setting.offsetXorDummySize;
7889
}
7990

8091
private void OnDisable()
@@ -119,25 +130,32 @@ private void _CryptogramType(CryptogramType cryptogramType)
119130
case CryptogramType.Offset:
120131
this._DrawOffsetView();
121132
break;
122-
case CryptogramType.Xor:
133+
case CryptogramType.XOR:
123134
this._DrawXorView();
124135
break;
125-
case CryptogramType.HT2Xor:
136+
case CryptogramType.HT2XOR:
126137
this._DrawHT2XorView();
127138
break;
128-
case CryptogramType.HT2XorPlus:
139+
case CryptogramType.HT2XORPlus:
129140
this._DrawHT2XorPlusView();
130141
break;
131-
case CryptogramType.Aes:
142+
case CryptogramType.AES:
132143
this._DrawAesView();
133144
break;
145+
case CryptogramType.ChaCha20:
146+
this._DrawChaCha20View();
147+
break;
148+
case CryptogramType.XXTEA:
149+
this._DrawXXTEAView();
150+
break;
151+
case CryptogramType.OffsetXOR:
152+
this._DrawOffsetXorView();
153+
break;
134154
}
135155
}
136156

137157
#region Offset
138158
[SerializeField]
139-
public int randomSeed = 1;
140-
[SerializeField]
141159
public int dummySize = 0;
142160
private void _DrawOffsetView()
143161
{
@@ -156,9 +174,6 @@ private void _DrawOffsetView()
156174
GUILayout.Label(new GUIContent("Offset Settings"), centeredStyle);
157175
EditorGUILayout.Space();
158176

159-
this.randomSeed = EditorGUILayout.IntField(new GUIContent("Random Seed", "Fixed random values."), this.randomSeed);
160-
if (this.randomSeed <= 0) this.randomSeed = 1;
161-
162177
this.dummySize = EditorGUILayout.IntField(new GUIContent("Offset Dummy Size", "Add dummy bytes into front of file (per byte = Random 0 ~ 255)."), this.dummySize);
163178
if (this.dummySize < 0) this.dummySize = 0;
164179

@@ -288,9 +303,9 @@ private void _DrawHT2XorPlusView()
288303

289304
#region AES
290305
[SerializeField]
291-
public string aesKey = "file_key";
306+
public string aesKey = "aes_key";
292307
[SerializeField]
293-
public string aesIv = "file_iv";
308+
public string aesIv = "aes_iv";
294309
private void _DrawAesView()
295310
{
296311
EditorGUILayout.Space();
@@ -317,6 +332,101 @@ private void _DrawAesView()
317332
}
318333
#endregion
319334

335+
#region ChaCha20
336+
[SerializeField]
337+
public string chacha20Key = "chacha20_key";
338+
[SerializeField]
339+
public string chacha20Nonce = "chacha20_nonce";
340+
[SerializeField]
341+
public uint chacha20Counter = 1;
342+
private void _DrawChaCha20View()
343+
{
344+
EditorGUILayout.Space();
345+
346+
GUIStyle style = new GUIStyle();
347+
var bg = new Texture2D(1, 1);
348+
ColorUtility.TryParseHtmlString("#1e3836", out Color color);
349+
Color[] pixels = Enumerable.Repeat(color, Screen.width * Screen.height).ToArray();
350+
bg.SetPixels(pixels);
351+
bg.Apply();
352+
style.normal.background = bg;
353+
EditorGUILayout.BeginVertical(style);
354+
var centeredStyle = new GUIStyle(GUI.skin.GetStyle("Label"));
355+
centeredStyle.alignment = TextAnchor.UpperCenter;
356+
GUILayout.Label(new GUIContent("ChaCha20 Settings"), centeredStyle);
357+
EditorGUILayout.Space();
358+
359+
this.chacha20Key = EditorGUILayout.TextField("ChaCha20 KEY", this.chacha20Key);
360+
this.chacha20Nonce = EditorGUILayout.TextField("ChaCha20 NONCE", this.chacha20Nonce);
361+
this.chacha20Counter = Convert.ToUInt32(EditorGUILayout.IntField("ChaCha20 COUNTER", Convert.ToInt32(this.chacha20Counter)));
362+
363+
this._DrawOperateButtonsView(this.cryptogramType);
364+
365+
EditorGUILayout.EndVertical();
366+
}
367+
#endregion
368+
369+
#region XXTEA
370+
[SerializeField]
371+
public string xxteaKey = "xxtea_key";
372+
private void _DrawXXTEAView()
373+
{
374+
EditorGUILayout.Space();
375+
376+
GUIStyle style = new GUIStyle();
377+
var bg = new Texture2D(1, 1);
378+
ColorUtility.TryParseHtmlString("#1e3836", out Color color);
379+
Color[] pixels = Enumerable.Repeat(color, Screen.width * Screen.height).ToArray();
380+
bg.SetPixels(pixels);
381+
bg.Apply();
382+
style.normal.background = bg;
383+
EditorGUILayout.BeginVertical(style);
384+
var centeredStyle = new GUIStyle(GUI.skin.GetStyle("Label"));
385+
centeredStyle.alignment = TextAnchor.UpperCenter;
386+
GUILayout.Label(new GUIContent("XXTEA Settings"), centeredStyle);
387+
EditorGUILayout.Space();
388+
389+
this.xxteaKey = EditorGUILayout.TextField("XXTEA KEY", this.xxteaKey);
390+
391+
this._DrawOperateButtonsView(this.cryptogramType);
392+
393+
EditorGUILayout.EndVertical();
394+
}
395+
#endregion
396+
397+
#region OffsetXOR
398+
[SerializeField]
399+
public int offsetXorKey = 1;
400+
public int offsetXorDummySize = 1;
401+
private void _DrawOffsetXorView()
402+
{
403+
EditorGUILayout.Space();
404+
405+
GUIStyle style = new GUIStyle();
406+
var bg = new Texture2D(1, 1);
407+
ColorUtility.TryParseHtmlString("#1e3836", out Color color);
408+
Color[] pixels = Enumerable.Repeat(color, Screen.width * Screen.height).ToArray();
409+
bg.SetPixels(pixels);
410+
bg.Apply();
411+
style.normal.background = bg;
412+
EditorGUILayout.BeginVertical(style);
413+
var centeredStyle = new GUIStyle(GUI.skin.GetStyle("Label"));
414+
centeredStyle.alignment = TextAnchor.UpperCenter;
415+
GUILayout.Label(new GUIContent("OffsetXOR Settings"), centeredStyle);
416+
EditorGUILayout.Space();
417+
418+
this.offsetXorKey = EditorGUILayout.IntField("OffsetXOR KEY (0 ~ 255)", this.offsetXorKey);
419+
if (this.offsetXorKey < 0) this.offsetXorKey = 0;
420+
else if (this.offsetXorKey > 255) this.offsetXorKey = 255;
421+
this.offsetXorDummySize = EditorGUILayout.IntField(new GUIContent("OffsetXOR Dummy Size", "Add dummy bytes into front of file (per byte = Random 0 ~ 255)."), this.offsetXorDummySize);
422+
if (this.offsetXorDummySize < 0) this.offsetXorDummySize = 0;
423+
424+
this._DrawOperateButtonsView(this.cryptogramType);
425+
426+
EditorGUILayout.EndVertical();
427+
}
428+
#endregion
429+
320430
private void _DrawOperateButtonsView(CryptogramType cryptogramType)
321431
{
322432
EditorGUILayout.BeginHorizontal();
@@ -331,19 +441,19 @@ private void _DrawOperateButtonsView(CryptogramType cryptogramType)
331441
CryptogramUtility.OffsetDecryptBundleFiles(this.sourceFolder, this.dummySize);
332442
EditorUtility.DisplayDialog("Crytogram Message", "[OFFSET] Decrypt Process.", "OK");
333443
break;
334-
case CryptogramType.Xor:
444+
case CryptogramType.XOR:
335445
CryptogramUtility.XorDecryptBundleFiles(this.sourceFolder, (byte)this.xorKey);
336446
EditorUtility.DisplayDialog("Crytogram Message", "[XOR] Decrypt Process.", "OK");
337447
break;
338-
case CryptogramType.HT2Xor:
448+
case CryptogramType.HT2XOR:
339449
CryptogramUtility.HT2XorDecryptBundleFiles(this.sourceFolder, (byte)this.hXorKey, (byte)this.tXorKey, (byte)this.jXorKey);
340450
EditorUtility.DisplayDialog("Crytogram Message", "[Head-Tail 2 XOR] Decrypt Process.", "OK");
341451
break;
342-
case CryptogramType.HT2XorPlus:
452+
case CryptogramType.HT2XORPlus:
343453
CryptogramUtility.HT2XorPlusDecryptBundleFiles(this.sourceFolder, (byte)this.hXorPlusKey, (byte)this.tXorPlusKey, (byte)this.j1XorPlusKey, (byte)this.j2XorPlusKey);
344454
EditorUtility.DisplayDialog("Crytogram Message", "[Head-Tail 2 XOR Plus] Decrypt Process.", "OK");
345455
break;
346-
case CryptogramType.Aes:
456+
case CryptogramType.AES:
347457
if (string.IsNullOrEmpty(this.aesKey) || string.IsNullOrEmpty(this.aesIv))
348458
{
349459
EditorUtility.DisplayDialog("Crytogram Message", "[AES] KEY or IV is Empty!!! Can't process.", "OK");
@@ -352,6 +462,28 @@ private void _DrawOperateButtonsView(CryptogramType cryptogramType)
352462
CryptogramUtility.AesDecryptBundleFiles(this.sourceFolder, this.aesKey, this.aesIv);
353463
EditorUtility.DisplayDialog("Crytogram Message", "[AES] Decrypt Process.", "OK");
354464
break;
465+
case CryptogramType.ChaCha20:
466+
if (string.IsNullOrEmpty(this.chacha20Key) || string.IsNullOrEmpty(this.chacha20Nonce))
467+
{
468+
EditorUtility.DisplayDialog("Crytogram Message", "[ChaCha20] KEY or NONCE is Empty!!! Can't process.", "OK");
469+
break;
470+
}
471+
CryptogramUtility.ChaCha20DecryptBundleFiles(this.sourceFolder, this.chacha20Key, this.chacha20Nonce, this.chacha20Counter);
472+
EditorUtility.DisplayDialog("Crytogram Message", "[ChaCha20] Decrypt Process.", "OK");
473+
break;
474+
case CryptogramType.XXTEA:
475+
if (string.IsNullOrEmpty(this.xxteaKey))
476+
{
477+
EditorUtility.DisplayDialog("Crytogram Message", "[XXTEA] KEY is Empty!!! Can't process.", "OK");
478+
break;
479+
}
480+
CryptogramUtility.XXTEADecryptBundleFiles(this.sourceFolder, this.xxteaKey);
481+
EditorUtility.DisplayDialog("Crytogram Message", "[XXTEA] Decrypt Process.", "OK");
482+
break;
483+
case CryptogramType.OffsetXOR:
484+
CryptogramUtility.OffsetXorDecryptBundleFiles(this.sourceFolder, (byte)this.offsetXorKey, this.offsetXorDummySize);
485+
EditorUtility.DisplayDialog("Crytogram Message", "[OffsetXOR] Decrypt Process.", "OK");
486+
break;
355487
}
356488
}
357489
GUI.backgroundColor = bc;
@@ -363,22 +495,22 @@ private void _DrawOperateButtonsView(CryptogramType cryptogramType)
363495
switch (cryptogramType)
364496
{
365497
case CryptogramType.Offset:
366-
CryptogramUtility.OffsetEncryptBundleFiles(this.sourceFolder, this.randomSeed, this.dummySize);
498+
CryptogramUtility.OffsetEncryptBundleFiles(this.sourceFolder, this.dummySize);
367499
EditorUtility.DisplayDialog("Crytogram Message", "[OFFSET] Encrypt Process.", "OK");
368500
break;
369-
case CryptogramType.Xor:
501+
case CryptogramType.XOR:
370502
CryptogramUtility.XorEncryptBundleFiles(this.sourceFolder, (byte)this.xorKey);
371503
EditorUtility.DisplayDialog("Crytogram Message", "[XOR] Encrypt Process.", "OK");
372504
break;
373-
case CryptogramType.HT2Xor:
505+
case CryptogramType.HT2XOR:
374506
CryptogramUtility.HT2XorEncryptBundleFiles(this.sourceFolder, (byte)this.hXorKey, (byte)this.tXorKey, (byte)this.jXorKey);
375507
EditorUtility.DisplayDialog("Crytogram Message", "[Head-Tail 2 XOR] Encrypt Process.", "OK");
376508
break;
377-
case CryptogramType.HT2XorPlus:
509+
case CryptogramType.HT2XORPlus:
378510
CryptogramUtility.HT2XorPlusEncryptBundleFiles(this.sourceFolder, (byte)this.hXorPlusKey, (byte)this.tXorPlusKey, (byte)this.j1XorPlusKey, (byte)this.j2XorPlusKey);
379511
EditorUtility.DisplayDialog("Crytogram Message", "[Head-Tail 2 XOR Plus] Encrypt Process.", "OK");
380512
break;
381-
case CryptogramType.Aes:
513+
case CryptogramType.AES:
382514
if (string.IsNullOrEmpty(this.aesKey) || string.IsNullOrEmpty(this.aesIv))
383515
{
384516
EditorUtility.DisplayDialog("Crytogram Message", "[AES] KEY or IV is Empty!!! Can't process.", "OK");
@@ -387,6 +519,28 @@ private void _DrawOperateButtonsView(CryptogramType cryptogramType)
387519
CryptogramUtility.AesEncryptBundleFiles(this.sourceFolder, this.aesKey, this.aesIv);
388520
EditorUtility.DisplayDialog("Crytogram Message", "[AES] Encrypt Process.", "OK");
389521
break;
522+
case CryptogramType.ChaCha20:
523+
if (string.IsNullOrEmpty(this.chacha20Key) || string.IsNullOrEmpty(this.chacha20Nonce))
524+
{
525+
EditorUtility.DisplayDialog("Crytogram Message", "[ChaCha20] KEY or NONCE is Empty!!! Can't process.", "OK");
526+
break;
527+
}
528+
CryptogramUtility.ChaCha20EncryptBundleFiles(this.sourceFolder, this.chacha20Key, this.chacha20Nonce, this.chacha20Counter);
529+
EditorUtility.DisplayDialog("Crytogram Message", "[ChaCha20] Encrypt Process.", "OK");
530+
break;
531+
case CryptogramType.XXTEA:
532+
if (string.IsNullOrEmpty(this.xxteaKey))
533+
{
534+
EditorUtility.DisplayDialog("Crytogram Message", "[XXTEA] KEY is Empty!!! Can't process.", "OK");
535+
break;
536+
}
537+
CryptogramUtility.XXTEAEncryptBundleFiles(this.sourceFolder, this.xxteaKey);
538+
EditorUtility.DisplayDialog("Crytogram Message", "[XXTEA] Encrypt Process.", "OK");
539+
break;
540+
case CryptogramType.OffsetXOR:
541+
CryptogramUtility.OffsetXorEncryptBundleFiles(this.sourceFolder, (byte)this.offsetXorKey, this.offsetXorDummySize);
542+
EditorUtility.DisplayDialog("Crytogram Message", "[OffsetXOR] Encrypt Process.", "OK");
543+
break;
390544
}
391545
}
392546
GUI.backgroundColor = bc;

0 commit comments

Comments
 (0)