From 38140485c00362b617caf2d8691bf79144e6c19d Mon Sep 17 00:00:00 2001 From: James Cahill Date: Wed, 6 Nov 2019 18:58:54 +0000 Subject: [PATCH 01/15] KeyDB saving initial --- Assets/Debug/DebugScene/Latest.cs | 21 +++++++- Assets/MDMulti/Scripts/KeyDB.cs | 80 ++++++++++++++++++++++++++++ Assets/MDMulti/Scripts/KeyDB.cs.meta | 11 ++++ 3 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 Assets/MDMulti/Scripts/KeyDB.cs create mode 100644 Assets/MDMulti/Scripts/KeyDB.cs.meta diff --git a/Assets/Debug/DebugScene/Latest.cs b/Assets/Debug/DebugScene/Latest.cs index e0cd9ec..8688e64 100644 --- a/Assets/Debug/DebugScene/Latest.cs +++ b/Assets/Debug/DebugScene/Latest.cs @@ -5,12 +5,29 @@ namespace MDMulti_DEBUG.DebugScene { public class Latest : MonoBehaviour { - public void Latest1() + public async void Latest1() { Debug.Log("L"); //Debug.Log(MDMulti.SHA2Helper.ComputeHash(new byte[0])); //Debug.Log(MDMulti.SHA2Helper.ComputeHashStr("")); - MDMulti.ConstantsHelper.Test(); + + //MDMulti.ConstantsHelper.Test(); + + + // Doesn't really fit in .NET + + // KEYDB Testing + MDMulti.Net.KeyDB.KeyFile s = MDMulti.Net.KeyDB.createNewFile(); + MDMulti.Net.KeyDB.KeyItem it = new MDMulti.Net.KeyDB.KeyItem(); + + it.x509Pub = await MDMulti.CertHelper.GetCertificateFromFile("p4.crt"); + + UnityEngine.Debug.Log(it.actualID); + UnityEngine.Debug.Log(it.x509Pub); + + s.keys.Add(it); + + s.SaveToFile(); } public void Latest2() diff --git a/Assets/MDMulti/Scripts/KeyDB.cs b/Assets/MDMulti/Scripts/KeyDB.cs new file mode 100644 index 0000000..b274d8f --- /dev/null +++ b/Assets/MDMulti/Scripts/KeyDB.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Security.Cryptography.X509Certificates; +using Newtonsoft.Json; + +namespace MDMulti.Net +{ + public class KeyDB + { + public static KeyFile createNewFile() + { + return new KeyFile(); + } + + /// + /// Schema / Class file for the Root Key File + /// + public class KeyFile + { + // We do it this way so that it is still serialized as JSON. + public int version { get { return 1; } } + public List keys; + + public KeyFile() + { + keys = new List(); + } + + public void SaveToFile() + { + StorageHelper.SaveToFileAlternate(JsonConvert.SerializeObject(this), "peerdb.mdm.json"); + } + + } + + /// + /// Schema / Class file for the Key Item(s) + /// + public class KeyItem + { + public string actualID { get { return x509Pub.GetSerialNumberString(); } } + + [JsonConverter(typeof(X509Certificate2Converter))] + public X509Certificate2 x509Pub; + + public X509Certificate2 getCert() + { + return new X509Certificate2(x509Pub); + } + } + + /// + /// NewtonSoft JSON converter to serialize an X509Certificate2 to a Base64 string. + /// Uses + /// + public class X509Certificate2Converter : JsonConverter + { + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + X509Certificate2 cert = value as X509Certificate2; + writer.WriteValue(CertHelper.ExportCertificate(cert)); + } + + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + throw new NotImplementedException("Unnecessary because CanRead is false. The type will skip the converter."); + } + + public override bool CanRead + { + get { return false; } + } + + public override bool CanConvert(Type objectType) + { + return objectType == typeof(X509Certificate2); + } + } + } +} diff --git a/Assets/MDMulti/Scripts/KeyDB.cs.meta b/Assets/MDMulti/Scripts/KeyDB.cs.meta new file mode 100644 index 0000000..e91be03 --- /dev/null +++ b/Assets/MDMulti/Scripts/KeyDB.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e0ae558b3e2876c45b8ef8f2b3e52475 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From f566f30d2038778bcc269b87167c9004033538ca Mon Sep 17 00:00:00 2001 From: James Cahill Date: Thu, 7 Nov 2019 08:21:14 +0000 Subject: [PATCH 02/15] KeyDB saving and loading --- Assets/Debug/DebugScene/Latest.cs | 14 +++++++++++--- Assets/MDMulti/Scripts/KeyDB.cs | 21 ++++++++++++++------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/Assets/Debug/DebugScene/Latest.cs b/Assets/Debug/DebugScene/Latest.cs index 8688e64..d594e1f 100644 --- a/Assets/Debug/DebugScene/Latest.cs +++ b/Assets/Debug/DebugScene/Latest.cs @@ -17,8 +17,8 @@ public async void Latest1() // Doesn't really fit in .NET // KEYDB Testing - MDMulti.Net.KeyDB.KeyFile s = MDMulti.Net.KeyDB.createNewFile(); - MDMulti.Net.KeyDB.KeyItem it = new MDMulti.Net.KeyDB.KeyItem(); + MDMulti.KeyDB.KeyFile s = MDMulti.KeyDB.CreateNewFile(); + MDMulti.KeyDB.KeyItem it = new MDMulti.KeyDB.KeyItem(); it.x509Pub = await MDMulti.CertHelper.GetCertificateFromFile("p4.crt"); @@ -30,8 +30,9 @@ public async void Latest1() s.SaveToFile(); } - public void Latest2() + public async void Latest2() { + /* Debug.Log("L2"); byte[] s = MDMulti.Net.Core.GenerateAndAddHash(Encoding.UTF8.GetBytes("This is a SHA256 function.")); Debug.Log(MDMulti.Net.Core.GetHash(s)); @@ -42,6 +43,13 @@ public void Latest2() Debug.Log("MSG: " + Encoding.UTF8.GetString(ss.Item1)); Debug.Log("HASH: " + ss.Item2); + */ + + var kf = await MDMulti.KeyDB.LoadFromFile(); + + Debug.Log((kf).keys[0].actualID); + Debug.Log(MDMulti.CertHelper.IsUserCertificate(kf.keys[0].x509Pub)); + } } } \ No newline at end of file diff --git a/Assets/MDMulti/Scripts/KeyDB.cs b/Assets/MDMulti/Scripts/KeyDB.cs index b274d8f..31447b3 100644 --- a/Assets/MDMulti/Scripts/KeyDB.cs +++ b/Assets/MDMulti/Scripts/KeyDB.cs @@ -1,17 +1,25 @@ using System; using System.Collections.Generic; using System.Security.Cryptography.X509Certificates; +using System.Text; +using System.Threading.Tasks; using Newtonsoft.Json; -namespace MDMulti.Net +namespace MDMulti { public class KeyDB { - public static KeyFile createNewFile() + public static KeyFile CreateNewFile() { return new KeyFile(); } + public static async Task LoadFromFile() + { + string data = Encoding.UTF8.GetString(await StorageHelper.ReadFileByte("peerdb.mdm.json")); + return JsonConvert.DeserializeObject(data); + } + /// /// Schema / Class file for the Root Key File /// @@ -63,13 +71,12 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - throw new NotImplementedException("Unnecessary because CanRead is false. The type will skip the converter."); + byte[] certData = Convert.FromBase64String((string)reader.Value); + return new X509Certificate2(certData); } - public override bool CanRead - { - get { return false; } - } + // CanRead is not required as it is enabled by default + // It is also takes no arguments public override bool CanConvert(Type objectType) { From 9b5a18e8e4b246c42518f96480ee38a3ca7753cb Mon Sep 17 00:00:00 2001 From: James Cahill Date: Mon, 11 Nov 2019 19:22:00 +0000 Subject: [PATCH 03/15] [KeyDB] AddX509 function --- Assets/Debug/DebugScene/Latest.cs | 3 ++- Assets/MDMulti/Scripts/KeyDB.cs | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Assets/Debug/DebugScene/Latest.cs b/Assets/Debug/DebugScene/Latest.cs index d594e1f..cd3ba0c 100644 --- a/Assets/Debug/DebugScene/Latest.cs +++ b/Assets/Debug/DebugScene/Latest.cs @@ -10,7 +10,7 @@ public async void Latest1() Debug.Log("L"); //Debug.Log(MDMulti.SHA2Helper.ComputeHash(new byte[0])); //Debug.Log(MDMulti.SHA2Helper.ComputeHashStr("")); - + //MDMulti.ConstantsHelper.Test(); @@ -26,6 +26,7 @@ public async void Latest1() UnityEngine.Debug.Log(it.x509Pub); s.keys.Add(it); + s.AddX509(await MDMulti.CertHelper.GetCertificateFromFile("p4.crt")); s.SaveToFile(); } diff --git a/Assets/MDMulti/Scripts/KeyDB.cs b/Assets/MDMulti/Scripts/KeyDB.cs index 31447b3..c46cb59 100644 --- a/Assets/MDMulti/Scripts/KeyDB.cs +++ b/Assets/MDMulti/Scripts/KeyDB.cs @@ -39,6 +39,17 @@ public void SaveToFile() StorageHelper.SaveToFileAlternate(JsonConvert.SerializeObject(this), "peerdb.mdm.json"); } + /// + /// Add a new certificate item to the database. + /// + /// + public void AddX509(X509Certificate2 cert) + { + KeyItem ki = new KeyItem(); + ki.x509Pub = cert; + keys.Add(ki); + } + } /// From 3c143ee973d254cc3eddcc3b817643b3402f7e52 Mon Sep 17 00:00:00 2001 From: James Cahill Date: Mon, 11 Nov 2019 20:14:31 +0000 Subject: [PATCH 04/15] Constants2 and KeyItem X509 construct --- Assets/Debug/DebugScene/Latest.cs | 8 +------- Assets/MDMulti/Resources/constants.json | 8 ++++++-- Assets/MDMulti/Scripts/Constants.cs | 12 ++++++++++++ Assets/MDMulti/Scripts/KeyDB.cs | 26 +++++++++++++++++++------ 4 files changed, 39 insertions(+), 15 deletions(-) diff --git a/Assets/Debug/DebugScene/Latest.cs b/Assets/Debug/DebugScene/Latest.cs index cd3ba0c..1c00363 100644 --- a/Assets/Debug/DebugScene/Latest.cs +++ b/Assets/Debug/DebugScene/Latest.cs @@ -18,14 +18,8 @@ public async void Latest1() // KEYDB Testing MDMulti.KeyDB.KeyFile s = MDMulti.KeyDB.CreateNewFile(); - MDMulti.KeyDB.KeyItem it = new MDMulti.KeyDB.KeyItem(); - it.x509Pub = await MDMulti.CertHelper.GetCertificateFromFile("p4.crt"); - - UnityEngine.Debug.Log(it.actualID); - UnityEngine.Debug.Log(it.x509Pub); - - s.keys.Add(it); + s.keys.Add(new MDMulti.KeyDB.KeyItem(await MDMulti.CertHelper.GetCertificateFromFile("p4.crt"))); s.AddX509(await MDMulti.CertHelper.GetCertificateFromFile("p4.crt")); s.SaveToFile(); diff --git a/Assets/MDMulti/Resources/constants.json b/Assets/MDMulti/Resources/constants.json index c6d5abb..a0711d4 100644 --- a/Assets/MDMulti/Resources/constants.json +++ b/Assets/MDMulti/Resources/constants.json @@ -1,8 +1,12 @@ { "this_loc": "https://raw.githubusercontent.com/mdmulti/constants/master/constants.json", - "version" : 1, + "version" : 2, "mdmc_version": 3, "mdms_version": 1, + "peerdb_file": { + "name": "peerdb.mdm.json", + "version": 1 + }, "oid": { "base": "1.3.6.1.4.1.54622.0.1" }, @@ -15,4 +19,4 @@ "port": 25816 } } -} +} \ No newline at end of file diff --git a/Assets/MDMulti/Scripts/Constants.cs b/Assets/MDMulti/Scripts/Constants.cs index a4a4c20..3077148 100644 --- a/Assets/MDMulti/Scripts/Constants.cs +++ b/Assets/MDMulti/Scripts/Constants.cs @@ -21,6 +21,9 @@ public partial class ConstantsObject [JsonProperty("mdms_version", Required = Required.Always)] public long MdmsVersion { get; set; } + [JsonProperty("peerdb_file", Required = Required.Always)] + public PeerdbFile PeerdbFile { get; set; } + [JsonProperty("oid", Required = Required.Always)] public Oid Oid { get; set; } @@ -58,6 +61,15 @@ public partial class Oid public string Base { get; set; } } + public partial class PeerdbFile + { + [JsonProperty("name", Required = Required.Always)] + public string Name { get; set; } + + [JsonProperty("version", Required = Required.Always)] + public long Version { get; set; } + } + public partial class ConstantsObject { public static ConstantsObject FromJson(string json) => JsonConvert.DeserializeObject(json, MDMulti.Constants.Converter.Settings); diff --git a/Assets/MDMulti/Scripts/KeyDB.cs b/Assets/MDMulti/Scripts/KeyDB.cs index c46cb59..4f41286 100644 --- a/Assets/MDMulti/Scripts/KeyDB.cs +++ b/Assets/MDMulti/Scripts/KeyDB.cs @@ -9,6 +9,17 @@ namespace MDMulti { public class KeyDB { + /// + /// Get the PeerDB / KeyDB constants object. + /// See object . + /// + /// The constants object. + private static Constants.PeerdbFile GetConstants() + { + return ConstantsHelper.Get().PeerdbFile; + } + + // TODO: REMOVE public static KeyFile CreateNewFile() { return new KeyFile(); @@ -16,7 +27,7 @@ public static KeyFile CreateNewFile() public static async Task LoadFromFile() { - string data = Encoding.UTF8.GetString(await StorageHelper.ReadFileByte("peerdb.mdm.json")); + string data = Encoding.UTF8.GetString(await StorageHelper.ReadFileByte(GetConstants().Name)); return JsonConvert.DeserializeObject(data); } @@ -26,7 +37,7 @@ public static async Task LoadFromFile() public class KeyFile { // We do it this way so that it is still serialized as JSON. - public int version { get { return 1; } } + public int version { get { return (int)GetConstants().Version; } } public List keys; public KeyFile() @@ -36,7 +47,7 @@ public KeyFile() public void SaveToFile() { - StorageHelper.SaveToFileAlternate(JsonConvert.SerializeObject(this), "peerdb.mdm.json"); + StorageHelper.SaveToFileAlternate(JsonConvert.SerializeObject(this), GetConstants().Name); } /// @@ -45,9 +56,7 @@ public void SaveToFile() /// public void AddX509(X509Certificate2 cert) { - KeyItem ki = new KeyItem(); - ki.x509Pub = cert; - keys.Add(ki); + keys.Add(new KeyItem(cert)); } } @@ -57,6 +66,11 @@ public void AddX509(X509Certificate2 cert) /// public class KeyItem { + public KeyItem(X509Certificate2 cert) + { + x509Pub = cert; + } + public string actualID { get { return x509Pub.GetSerialNumberString(); } } [JsonConverter(typeof(X509Certificate2Converter))] From 9e77e9e826cf54f5ca43e49ece4f87b95125f13d Mon Sep 17 00:00:00 2001 From: James Cahill Date: Sun, 17 Nov 2019 18:49:24 +0000 Subject: [PATCH 05/15] Remove CreateNewFile & LoadFromFile and consolidate --- Assets/Debug/DebugScene/Latest.cs | 8 +++---- .../MDMulti/Scripts/Helpers/StorageHelper.cs | 2 ++ Assets/MDMulti/Scripts/KeyDB.cs | 24 ++++++++++++++----- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/Assets/Debug/DebugScene/Latest.cs b/Assets/Debug/DebugScene/Latest.cs index 1c00363..3c93fcb 100644 --- a/Assets/Debug/DebugScene/Latest.cs +++ b/Assets/Debug/DebugScene/Latest.cs @@ -17,9 +17,9 @@ public async void Latest1() // Doesn't really fit in .NET // KEYDB Testing - MDMulti.KeyDB.KeyFile s = MDMulti.KeyDB.CreateNewFile(); + MDMulti.PeerDB.KeyFile s = await MDMulti.PeerDB.GetObject(); ; - s.keys.Add(new MDMulti.KeyDB.KeyItem(await MDMulti.CertHelper.GetCertificateFromFile("p4.crt"))); + //s.keys.Add(new MDMulti.PeerDB.KeyItem(await MDMulti.CertHelper.GetCertificateFromFile("p4.crt"))); s.AddX509(await MDMulti.CertHelper.GetCertificateFromFile("p4.crt")); s.SaveToFile(); @@ -40,9 +40,9 @@ public async void Latest2() Debug.Log("HASH: " + ss.Item2); */ - var kf = await MDMulti.KeyDB.LoadFromFile(); + var kf = await MDMulti.PeerDB.GetObject(); - Debug.Log((kf).keys[0].actualID); + Debug.Log((kf).keys[0].apparentID); Debug.Log(MDMulti.CertHelper.IsUserCertificate(kf.keys[0].x509Pub)); } diff --git a/Assets/MDMulti/Scripts/Helpers/StorageHelper.cs b/Assets/MDMulti/Scripts/Helpers/StorageHelper.cs index 26a6b27..9375654 100644 --- a/Assets/MDMulti/Scripts/Helpers/StorageHelper.cs +++ b/Assets/MDMulti/Scripts/Helpers/StorageHelper.cs @@ -46,6 +46,7 @@ public static async Task ReadFileByte(string filename) FileStream file = File.OpenRead(GetFullPath(filename)); byte[] buffer = new byte[file.Length]; await file.ReadAsync(buffer, 0, (int)file.Length); + file.Close(); return buffer; } @@ -54,6 +55,7 @@ public static byte[] ReadFileByteSync(string filename) FileStream file = File.OpenRead(GetFullPath(filename)); byte[] buffer = new byte[file.Length]; file.Read(buffer, 0, (int)file.Length); + file.Close(); return buffer; } } diff --git a/Assets/MDMulti/Scripts/KeyDB.cs b/Assets/MDMulti/Scripts/KeyDB.cs index 4f41286..70ff5b6 100644 --- a/Assets/MDMulti/Scripts/KeyDB.cs +++ b/Assets/MDMulti/Scripts/KeyDB.cs @@ -7,7 +7,7 @@ namespace MDMulti { - public class KeyDB + public class PeerDB { /// /// Get the PeerDB / KeyDB constants object. @@ -19,13 +19,25 @@ private static Constants.PeerdbFile GetConstants() return ConstantsHelper.Get().PeerdbFile; } - // TODO: REMOVE - public static KeyFile CreateNewFile() + /// + /// Create or load an object + /// + /// + /// TODO: Extend FileExists to IsFileAvailable + public static async Task GetObject() { - return new KeyFile(); + if (!StorageHelper.FileExists(GetConstants().Name)) + { + UnityEngine.Debug.Log("KEYDB - Creating new"); + return new KeyFile(); + } else + { + UnityEngine.Debug.Log("KEYDB - Loading"); + return await LoadFromFile(); + } } - public static async Task LoadFromFile() + private static async Task LoadFromFile() { string data = Encoding.UTF8.GetString(await StorageHelper.ReadFileByte(GetConstants().Name)); return JsonConvert.DeserializeObject(data); @@ -71,7 +83,7 @@ public KeyItem(X509Certificate2 cert) x509Pub = cert; } - public string actualID { get { return x509Pub.GetSerialNumberString(); } } + public string apparentID { get { return x509Pub.GetSerialNumberString(); } } [JsonConverter(typeof(X509Certificate2Converter))] public X509Certificate2 x509Pub; From d6bf712070f170b296fb3f7c8cc3e695777c5330 Mon Sep 17 00:00:00 2001 From: James Cahill Date: Sun, 17 Nov 2019 18:50:08 +0000 Subject: [PATCH 06/15] Add a little note! --- Assets/MDMulti/Scripts/Helpers/StorageHelper.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Assets/MDMulti/Scripts/Helpers/StorageHelper.cs b/Assets/MDMulti/Scripts/Helpers/StorageHelper.cs index 9375654..6f131fc 100644 --- a/Assets/MDMulti/Scripts/Helpers/StorageHelper.cs +++ b/Assets/MDMulti/Scripts/Helpers/StorageHelper.cs @@ -3,6 +3,8 @@ using System.Threading.Tasks; using UnityEngine; +// Always close your streams to avoid IOExceptions! + namespace MDMulti { public class StorageHelper From 9ca99913f2516cd4345e5d1d4c1506a48271aea6 Mon Sep 17 00:00:00 2001 From: James Cahill Date: Sun, 17 Nov 2019 19:04:46 +0000 Subject: [PATCH 07/15] FileExistsAndIsJson instead of FileExists --- .../MDMulti/Scripts/Helpers/StorageHelper.cs | 42 ++++++++++++++++++- Assets/MDMulti/Scripts/KeyDB.cs | 2 +- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/Assets/MDMulti/Scripts/Helpers/StorageHelper.cs b/Assets/MDMulti/Scripts/Helpers/StorageHelper.cs index 6f131fc..f4470e4 100644 --- a/Assets/MDMulti/Scripts/Helpers/StorageHelper.cs +++ b/Assets/MDMulti/Scripts/Helpers/StorageHelper.cs @@ -1,5 +1,8 @@ -using System.IO; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System.IO; using System.Runtime.Serialization.Formatters.Binary; +using System.Text; using System.Threading.Tasks; using UnityEngine; @@ -32,6 +35,11 @@ public static void SaveToFile(System.SerializableAttribute data, string filename file.Close(); } + /// + /// Save to a File (Alternate) - Suitable for JSON files. + /// + /// The data to save. + /// The filename to use. public static void SaveToFileAlternate(string data, string filename) { Debug.Log(Application.persistentDataPath); @@ -43,6 +51,38 @@ public static bool FileExists(string filename) return File.Exists(Application.persistentDataPath + "/" + filename); } + /// + /// Tests to see if the specified **existing** file is valid JSON. + /// + /// File to test + /// async Boolean exists + private static async Task FileIsJson(string filename) + { + try + { + JObject.Parse(Encoding.UTF8.GetString(await ReadFileByte(filename))); + // If we get to this line then the file is valid JSON. + return true; + } catch (JsonReaderException) + { + // File is not valid JSON. + return false; + } + } + + public static async Task FileExistsAndIsJson(string filename) + { + bool exists = FileExists(filename); + + if (!exists) + { + return false; + } else + { + return await FileIsJson(filename); + } + } + public static async Task ReadFileByte(string filename) { FileStream file = File.OpenRead(GetFullPath(filename)); diff --git a/Assets/MDMulti/Scripts/KeyDB.cs b/Assets/MDMulti/Scripts/KeyDB.cs index 70ff5b6..663bdfa 100644 --- a/Assets/MDMulti/Scripts/KeyDB.cs +++ b/Assets/MDMulti/Scripts/KeyDB.cs @@ -26,7 +26,7 @@ private static Constants.PeerdbFile GetConstants() /// TODO: Extend FileExists to IsFileAvailable public static async Task GetObject() { - if (!StorageHelper.FileExists(GetConstants().Name)) + if (!await StorageHelper.FileExistsAndIsJson(GetConstants().Name)) { UnityEngine.Debug.Log("KEYDB - Creating new"); return new KeyFile(); From 6f2fa0b85ffeeacbeace95915c436f96346a8965 Mon Sep 17 00:00:00 2001 From: James Cahill Date: Sat, 23 Nov 2019 15:01:51 +0000 Subject: [PATCH 08/15] initial addX509IfNotPresent comparing apparentID only --- Assets/Debug/DebugScene/Latest.cs | 5 ++--- Assets/MDMulti/Scripts/KeyDB.cs | 29 ++++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/Assets/Debug/DebugScene/Latest.cs b/Assets/Debug/DebugScene/Latest.cs index 3c93fcb..94a2df1 100644 --- a/Assets/Debug/DebugScene/Latest.cs +++ b/Assets/Debug/DebugScene/Latest.cs @@ -17,11 +17,10 @@ public async void Latest1() // Doesn't really fit in .NET // KEYDB Testing - MDMulti.PeerDB.KeyFile s = await MDMulti.PeerDB.GetObject(); ; + MDMulti.PeerDB.KeyFile s = await MDMulti.PeerDB.GetObject(); //s.keys.Add(new MDMulti.PeerDB.KeyItem(await MDMulti.CertHelper.GetCertificateFromFile("p4.crt"))); - s.AddX509(await MDMulti.CertHelper.GetCertificateFromFile("p4.crt")); - + s.AddX509IfNotPresent(await MDMulti.CertHelper.GetCertificateFromFile("p4.crt")); s.SaveToFile(); } diff --git a/Assets/MDMulti/Scripts/KeyDB.cs b/Assets/MDMulti/Scripts/KeyDB.cs index 663bdfa..2cbc5e8 100644 --- a/Assets/MDMulti/Scripts/KeyDB.cs +++ b/Assets/MDMulti/Scripts/KeyDB.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading.Tasks; @@ -63,13 +64,35 @@ public void SaveToFile() } /// - /// Add a new certificate item to the database. + /// Add a new certificate item to the database, even if it already exists. /// /// - public void AddX509(X509Certificate2 cert) + public void AddX509Force(X509Certificate2 cert) { keys.Add(new KeyItem(cert)); } + + /// + /// Add a new certificate item to the database if it was not already present. + /// + /// + public void AddX509IfNotPresent(X509Certificate2 cert) + { + UnityEngine.Debug.Log(cert.GetSerialNumberString().ToUpper()); + //var i = keys.Exists(s => s.apparentID == cert.GetSerialNumberString().ToUpper()); + //var exists = keys.Find(delegate (KeyItem ki) + //{ + // return ki.apparentID == cert.GetSerialNumberString().ToUpper(); + //}); + var exists = keys.Any(item => item.apparentID == new KeyItem(cert).apparentID); + UnityEngine.Debug.Log("AINP: EXISTS " + exists); + + if (!exists) + { + AddX509Force(cert); + UnityEngine.Debug.Log("ADDED"); + } + } } @@ -83,7 +106,7 @@ public KeyItem(X509Certificate2 cert) x509Pub = cert; } - public string apparentID { get { return x509Pub.GetSerialNumberString(); } } + public string apparentID { get { return x509Pub.GetSerialNumberString().ToUpper(); ; } } [JsonConverter(typeof(X509Certificate2Converter))] public X509Certificate2 x509Pub; From 8bfc5dca2be7a53ad83cb766595d8ed1fcb5c6eb Mon Sep 17 00:00:00 2001 From: James Cahill Date: Sat, 23 Nov 2019 15:41:22 +0000 Subject: [PATCH 09/15] fully implemented addX509IfNotPresent --- Assets/Debug/DebugScene/Latest.cs | 6 ++-- Assets/MDMulti/Scripts/KeyDB.cs | 53 ++++++++++++++++++++++--------- 2 files changed, 40 insertions(+), 19 deletions(-) diff --git a/Assets/Debug/DebugScene/Latest.cs b/Assets/Debug/DebugScene/Latest.cs index 94a2df1..060814b 100644 --- a/Assets/Debug/DebugScene/Latest.cs +++ b/Assets/Debug/DebugScene/Latest.cs @@ -14,8 +14,6 @@ public async void Latest1() //MDMulti.ConstantsHelper.Test(); - // Doesn't really fit in .NET - // KEYDB Testing MDMulti.PeerDB.KeyFile s = await MDMulti.PeerDB.GetObject(); @@ -41,8 +39,8 @@ public async void Latest2() var kf = await MDMulti.PeerDB.GetObject(); - Debug.Log((kf).keys[0].apparentID); - Debug.Log(MDMulti.CertHelper.IsUserCertificate(kf.keys[0].x509Pub)); + Debug.Log(kf.keys[0].GetAID()); + Debug.Log(MDMulti.CertHelper.IsUserCertificate(kf.keys[0].GetCert())); } } diff --git a/Assets/MDMulti/Scripts/KeyDB.cs b/Assets/MDMulti/Scripts/KeyDB.cs index 2cbc5e8..2addc6e 100644 --- a/Assets/MDMulti/Scripts/KeyDB.cs +++ b/Assets/MDMulti/Scripts/KeyDB.cs @@ -75,16 +75,12 @@ public void AddX509Force(X509Certificate2 cert) /// /// Add a new certificate item to the database if it was not already present. /// - /// public void AddX509IfNotPresent(X509Certificate2 cert) { - UnityEngine.Debug.Log(cert.GetSerialNumberString().ToUpper()); - //var i = keys.Exists(s => s.apparentID == cert.GetSerialNumberString().ToUpper()); - //var exists = keys.Find(delegate (KeyItem ki) - //{ - // return ki.apparentID == cert.GetSerialNumberString().ToUpper(); - //}); - var exists = keys.Any(item => item.apparentID == new KeyItem(cert).apparentID); + KeyItem certKI = new KeyItem(cert); + + bool exists = keys.Any(item => item.GetAID() == certKI.GetAID() && item.GetPublicKeyString() == certKI.GetPublicKeyString()); + UnityEngine.Debug.Log("AINP: EXISTS " + exists); if (!exists) @@ -103,22 +99,49 @@ public class KeyItem { public KeyItem(X509Certificate2 cert) { - x509Pub = cert; + _x509Pub = cert; } - public string apparentID { get { return x509Pub.GetSerialNumberString().ToUpper(); ; } } + [JsonProperty("apparentID")] + // This object has been made private so that we can + // freely rename these in the future without affecting compatability. + private string _apparentID { get { return GetCert().GetSerialNumberString().ToUpper(); } } + + [JsonProperty("x509Pub")] [JsonConverter(typeof(X509Certificate2Converter))] - public X509Certificate2 x509Pub; + // This object has been made private so that we can + // freely rename these in the future without affecting compatability. + private X509Certificate2 _x509Pub; + + /// + /// Get the X509Certificate2 object for this item. + /// + public X509Certificate2 GetCert() + { + return _x509Pub; + } - public X509Certificate2 getCert() + /// + /// Get the apparent ID for this item. + /// + public string GetAID() + { + return _apparentID; + } + + /// + /// Get the public key for this item as a string. + /// + /// The string representation of the public key. + public string GetPublicKeyString() { - return new X509Certificate2(x509Pub); + return GetCert().GetPublicKeyString(); } } /// - /// NewtonSoft JSON converter to serialize an X509Certificate2 to a Base64 string. + /// NewtonSoft.JSON converter to serialize an X509Certificate2 to a Base64 string. /// Uses /// public class X509Certificate2Converter : JsonConverter @@ -136,7 +159,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist } // CanRead is not required as it is enabled by default - // It is also takes no arguments + // It also takes no arguments public override bool CanConvert(Type objectType) { From ebce6be1b3204155da6abe675cde61ac13fd7ad0 Mon Sep 17 00:00:00 2001 From: James Cahill Date: Sat, 23 Nov 2019 15:45:26 +0000 Subject: [PATCH 10/15] Clean up addx509IfNotPresent --- Assets/MDMulti/Scripts/KeyDB.cs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Assets/MDMulti/Scripts/KeyDB.cs b/Assets/MDMulti/Scripts/KeyDB.cs index 2addc6e..f8f7eff 100644 --- a/Assets/MDMulti/Scripts/KeyDB.cs +++ b/Assets/MDMulti/Scripts/KeyDB.cs @@ -23,7 +23,6 @@ private static Constants.PeerdbFile GetConstants() /// /// Create or load an object /// - /// /// TODO: Extend FileExists to IsFileAvailable public static async Task GetObject() { @@ -80,14 +79,8 @@ public void AddX509IfNotPresent(X509Certificate2 cert) KeyItem certKI = new KeyItem(cert); bool exists = keys.Any(item => item.GetAID() == certKI.GetAID() && item.GetPublicKeyString() == certKI.GetPublicKeyString()); - - UnityEngine.Debug.Log("AINP: EXISTS " + exists); - - if (!exists) - { - AddX509Force(cert); - UnityEngine.Debug.Log("ADDED"); - } + + if (!exists) AddX509Force(cert); } } From ffeee25820ac7dbdfccea2d5ae7aff652fdbb369 Mon Sep 17 00:00:00 2001 From: James Cahill Date: Sat, 23 Nov 2019 16:28:40 +0000 Subject: [PATCH 11/15] Cleanup AsyncAwaitUtils folder and add README for source and licenses --- .../{Source => }/AwaitExtensions.cs | 0 .../{Source => }/AwaitExtensions.cs.meta | 0 .../AsyncAwaitUtil/{Source => }/Awaiters.cs | 0 .../{Source => }/Awaiters.cs.meta | 0 .../IEnumeratorAwaitExtensions.cs | 0 .../IEnumeratorAwaitExtensions.cs.meta | 0 .../AsyncAwaitUtil/{Source => }/Internal.meta | 0 .../Internal/AsyncCoroutineRunner.cs | 0 .../Internal/AsyncCoroutineRunner.cs.meta | 0 .../{Source => }/Internal/SyncContextUtil.cs | 0 .../Internal/SyncContextUtil.cs.meta | 0 Assets/Plugins/AsyncAwaitUtil/README.txt | 25 +++++++++++++++++++ Assets/Plugins/AsyncAwaitUtil/README.txt.meta | 7 ++++++ Assets/Plugins/AsyncAwaitUtil/Source.meta | 9 ------- .../{Source => }/TaskExtensions.cs | 0 .../{Source => }/TaskExtensions.cs.meta | 0 .../{Source => }/WaitForBackgroundThread.cs | 0 .../WaitForBackgroundThread.cs.meta | 0 .../{Source => }/WaitForUpdate.cs | 0 .../{Source => }/WaitForUpdate.cs.meta | 0 20 files changed, 32 insertions(+), 9 deletions(-) rename Assets/Plugins/AsyncAwaitUtil/{Source => }/AwaitExtensions.cs (100%) rename Assets/Plugins/AsyncAwaitUtil/{Source => }/AwaitExtensions.cs.meta (100%) rename Assets/Plugins/AsyncAwaitUtil/{Source => }/Awaiters.cs (100%) rename Assets/Plugins/AsyncAwaitUtil/{Source => }/Awaiters.cs.meta (100%) rename Assets/Plugins/AsyncAwaitUtil/{Source => }/IEnumeratorAwaitExtensions.cs (100%) rename Assets/Plugins/AsyncAwaitUtil/{Source => }/IEnumeratorAwaitExtensions.cs.meta (100%) rename Assets/Plugins/AsyncAwaitUtil/{Source => }/Internal.meta (100%) rename Assets/Plugins/AsyncAwaitUtil/{Source => }/Internal/AsyncCoroutineRunner.cs (100%) rename Assets/Plugins/AsyncAwaitUtil/{Source => }/Internal/AsyncCoroutineRunner.cs.meta (100%) rename Assets/Plugins/AsyncAwaitUtil/{Source => }/Internal/SyncContextUtil.cs (100%) rename Assets/Plugins/AsyncAwaitUtil/{Source => }/Internal/SyncContextUtil.cs.meta (100%) create mode 100644 Assets/Plugins/AsyncAwaitUtil/README.txt create mode 100644 Assets/Plugins/AsyncAwaitUtil/README.txt.meta delete mode 100644 Assets/Plugins/AsyncAwaitUtil/Source.meta rename Assets/Plugins/AsyncAwaitUtil/{Source => }/TaskExtensions.cs (100%) rename Assets/Plugins/AsyncAwaitUtil/{Source => }/TaskExtensions.cs.meta (100%) rename Assets/Plugins/AsyncAwaitUtil/{Source => }/WaitForBackgroundThread.cs (100%) rename Assets/Plugins/AsyncAwaitUtil/{Source => }/WaitForBackgroundThread.cs.meta (100%) rename Assets/Plugins/AsyncAwaitUtil/{Source => }/WaitForUpdate.cs (100%) rename Assets/Plugins/AsyncAwaitUtil/{Source => }/WaitForUpdate.cs.meta (100%) diff --git a/Assets/Plugins/AsyncAwaitUtil/Source/AwaitExtensions.cs b/Assets/Plugins/AsyncAwaitUtil/AwaitExtensions.cs similarity index 100% rename from Assets/Plugins/AsyncAwaitUtil/Source/AwaitExtensions.cs rename to Assets/Plugins/AsyncAwaitUtil/AwaitExtensions.cs diff --git a/Assets/Plugins/AsyncAwaitUtil/Source/AwaitExtensions.cs.meta b/Assets/Plugins/AsyncAwaitUtil/AwaitExtensions.cs.meta similarity index 100% rename from Assets/Plugins/AsyncAwaitUtil/Source/AwaitExtensions.cs.meta rename to Assets/Plugins/AsyncAwaitUtil/AwaitExtensions.cs.meta diff --git a/Assets/Plugins/AsyncAwaitUtil/Source/Awaiters.cs b/Assets/Plugins/AsyncAwaitUtil/Awaiters.cs similarity index 100% rename from Assets/Plugins/AsyncAwaitUtil/Source/Awaiters.cs rename to Assets/Plugins/AsyncAwaitUtil/Awaiters.cs diff --git a/Assets/Plugins/AsyncAwaitUtil/Source/Awaiters.cs.meta b/Assets/Plugins/AsyncAwaitUtil/Awaiters.cs.meta similarity index 100% rename from Assets/Plugins/AsyncAwaitUtil/Source/Awaiters.cs.meta rename to Assets/Plugins/AsyncAwaitUtil/Awaiters.cs.meta diff --git a/Assets/Plugins/AsyncAwaitUtil/Source/IEnumeratorAwaitExtensions.cs b/Assets/Plugins/AsyncAwaitUtil/IEnumeratorAwaitExtensions.cs similarity index 100% rename from Assets/Plugins/AsyncAwaitUtil/Source/IEnumeratorAwaitExtensions.cs rename to Assets/Plugins/AsyncAwaitUtil/IEnumeratorAwaitExtensions.cs diff --git a/Assets/Plugins/AsyncAwaitUtil/Source/IEnumeratorAwaitExtensions.cs.meta b/Assets/Plugins/AsyncAwaitUtil/IEnumeratorAwaitExtensions.cs.meta similarity index 100% rename from Assets/Plugins/AsyncAwaitUtil/Source/IEnumeratorAwaitExtensions.cs.meta rename to Assets/Plugins/AsyncAwaitUtil/IEnumeratorAwaitExtensions.cs.meta diff --git a/Assets/Plugins/AsyncAwaitUtil/Source/Internal.meta b/Assets/Plugins/AsyncAwaitUtil/Internal.meta similarity index 100% rename from Assets/Plugins/AsyncAwaitUtil/Source/Internal.meta rename to Assets/Plugins/AsyncAwaitUtil/Internal.meta diff --git a/Assets/Plugins/AsyncAwaitUtil/Source/Internal/AsyncCoroutineRunner.cs b/Assets/Plugins/AsyncAwaitUtil/Internal/AsyncCoroutineRunner.cs similarity index 100% rename from Assets/Plugins/AsyncAwaitUtil/Source/Internal/AsyncCoroutineRunner.cs rename to Assets/Plugins/AsyncAwaitUtil/Internal/AsyncCoroutineRunner.cs diff --git a/Assets/Plugins/AsyncAwaitUtil/Source/Internal/AsyncCoroutineRunner.cs.meta b/Assets/Plugins/AsyncAwaitUtil/Internal/AsyncCoroutineRunner.cs.meta similarity index 100% rename from Assets/Plugins/AsyncAwaitUtil/Source/Internal/AsyncCoroutineRunner.cs.meta rename to Assets/Plugins/AsyncAwaitUtil/Internal/AsyncCoroutineRunner.cs.meta diff --git a/Assets/Plugins/AsyncAwaitUtil/Source/Internal/SyncContextUtil.cs b/Assets/Plugins/AsyncAwaitUtil/Internal/SyncContextUtil.cs similarity index 100% rename from Assets/Plugins/AsyncAwaitUtil/Source/Internal/SyncContextUtil.cs rename to Assets/Plugins/AsyncAwaitUtil/Internal/SyncContextUtil.cs diff --git a/Assets/Plugins/AsyncAwaitUtil/Source/Internal/SyncContextUtil.cs.meta b/Assets/Plugins/AsyncAwaitUtil/Internal/SyncContextUtil.cs.meta similarity index 100% rename from Assets/Plugins/AsyncAwaitUtil/Source/Internal/SyncContextUtil.cs.meta rename to Assets/Plugins/AsyncAwaitUtil/Internal/SyncContextUtil.cs.meta diff --git a/Assets/Plugins/AsyncAwaitUtil/README.txt b/Assets/Plugins/AsyncAwaitUtil/README.txt new file mode 100644 index 0000000..740bb89 --- /dev/null +++ b/Assets/Plugins/AsyncAwaitUtil/README.txt @@ -0,0 +1,25 @@ +Original Project: https://github.com/modesttree/Unity3dAsyncAwaitUtil + +Original Project (Asset Store): https://assetstore.unity.com/packages/tools/integration/async-await-support-101056 + +-------------- + +Production fork at: https://github.com/mdmulti/unity-async-await-util + +Using commit: 9f776694a35dad430dd5718238798a429118ce31 as of last update. + +------------- + +Licensed under MIT. + +-------------- + +MIT License + +Copyright (c) 2016 Modest Tree Media Inc + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/Assets/Plugins/AsyncAwaitUtil/README.txt.meta b/Assets/Plugins/AsyncAwaitUtil/README.txt.meta new file mode 100644 index 0000000..c5317bd --- /dev/null +++ b/Assets/Plugins/AsyncAwaitUtil/README.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: dbd584c879ce51d4b85d455eb5331a24 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/AsyncAwaitUtil/Source.meta b/Assets/Plugins/AsyncAwaitUtil/Source.meta deleted file mode 100644 index d0b4231..0000000 --- a/Assets/Plugins/AsyncAwaitUtil/Source.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: 1855bfca81559324fa5a5d116a289bc6 -folderAsset: yes -timeCreated: 1506067485 -licenseType: Store -DefaultImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/AsyncAwaitUtil/Source/TaskExtensions.cs b/Assets/Plugins/AsyncAwaitUtil/TaskExtensions.cs similarity index 100% rename from Assets/Plugins/AsyncAwaitUtil/Source/TaskExtensions.cs rename to Assets/Plugins/AsyncAwaitUtil/TaskExtensions.cs diff --git a/Assets/Plugins/AsyncAwaitUtil/Source/TaskExtensions.cs.meta b/Assets/Plugins/AsyncAwaitUtil/TaskExtensions.cs.meta similarity index 100% rename from Assets/Plugins/AsyncAwaitUtil/Source/TaskExtensions.cs.meta rename to Assets/Plugins/AsyncAwaitUtil/TaskExtensions.cs.meta diff --git a/Assets/Plugins/AsyncAwaitUtil/Source/WaitForBackgroundThread.cs b/Assets/Plugins/AsyncAwaitUtil/WaitForBackgroundThread.cs similarity index 100% rename from Assets/Plugins/AsyncAwaitUtil/Source/WaitForBackgroundThread.cs rename to Assets/Plugins/AsyncAwaitUtil/WaitForBackgroundThread.cs diff --git a/Assets/Plugins/AsyncAwaitUtil/Source/WaitForBackgroundThread.cs.meta b/Assets/Plugins/AsyncAwaitUtil/WaitForBackgroundThread.cs.meta similarity index 100% rename from Assets/Plugins/AsyncAwaitUtil/Source/WaitForBackgroundThread.cs.meta rename to Assets/Plugins/AsyncAwaitUtil/WaitForBackgroundThread.cs.meta diff --git a/Assets/Plugins/AsyncAwaitUtil/Source/WaitForUpdate.cs b/Assets/Plugins/AsyncAwaitUtil/WaitForUpdate.cs similarity index 100% rename from Assets/Plugins/AsyncAwaitUtil/Source/WaitForUpdate.cs rename to Assets/Plugins/AsyncAwaitUtil/WaitForUpdate.cs diff --git a/Assets/Plugins/AsyncAwaitUtil/Source/WaitForUpdate.cs.meta b/Assets/Plugins/AsyncAwaitUtil/WaitForUpdate.cs.meta similarity index 100% rename from Assets/Plugins/AsyncAwaitUtil/Source/WaitForUpdate.cs.meta rename to Assets/Plugins/AsyncAwaitUtil/WaitForUpdate.cs.meta From 54e04e2921b67fd7181392e95d78fe18e9ba3641 Mon Sep 17 00:00:00 2001 From: James Cahill Date: Sun, 24 Nov 2019 10:00:26 +0000 Subject: [PATCH 12/15] Add ConstantsTest to DebugScene Closes #8. --- Assets/Debug/DebugScene/Constants.cs | 14 + Assets/Debug/DebugScene/Constants.cs.meta | 11 + Assets/Debug/DebugScene/DebugScene.unity | 481 ++++++++++++++++++ .../Scripts/Helpers/ConstantsHelper.cs | 8 +- 4 files changed, 509 insertions(+), 5 deletions(-) create mode 100644 Assets/Debug/DebugScene/Constants.cs create mode 100644 Assets/Debug/DebugScene/Constants.cs.meta diff --git a/Assets/Debug/DebugScene/Constants.cs b/Assets/Debug/DebugScene/Constants.cs new file mode 100644 index 0000000..b23bead --- /dev/null +++ b/Assets/Debug/DebugScene/Constants.cs @@ -0,0 +1,14 @@ +using MDMulti; +using UnityEngine; + +namespace MDMulti_DEBUG.DebugScene +{ + public class Constants : MonoBehaviour + { + public void LogTest() + { + MDMulti.Constants.ConstantsObject c = ConstantsHelper.Get(); + Debug.Log("ConstantsLogTest: Multicast Information\n" + c.Lan.Multicast.Address + ":" + c.Lan.Multicast.Port); + } + } +} \ No newline at end of file diff --git a/Assets/Debug/DebugScene/Constants.cs.meta b/Assets/Debug/DebugScene/Constants.cs.meta new file mode 100644 index 0000000..8baf42d --- /dev/null +++ b/Assets/Debug/DebugScene/Constants.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: afb9aa56d4d0270458c55b0c7cec3409 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Debug/DebugScene/DebugScene.unity b/Assets/Debug/DebugScene/DebugScene.unity index afbf3c6..d7f05aa 100644 --- a/Assets/Debug/DebugScene/DebugScene.unity +++ b/Assets/Debug/DebugScene/DebugScene.unity @@ -844,6 +844,125 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 150561442} m_CullTransparentMesh: 0 +--- !u!1001 &161055706 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 2013164481} + m_Modifications: + - target: {fileID: 1290408108987661695, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_Name + value: Constants + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_LocalRotation.y + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_RootOrder + value: 5 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_AnchoredPosition.x + value: 145 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_AnchoredPosition.y + value: -197.49 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_SizeDelta.x + value: 225 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_SizeDelta.y + value: 50 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_AnchorMin.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_AnchorMin.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_AnchorMax.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_AnchorMax.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_Pivot.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_Pivot.y + value: 0.5 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, type: 3} --- !u!1 &166911124 GameObject: m_ObjectHideFlags: 0 @@ -2184,6 +2303,135 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 619351115} m_CullTransparentMesh: 0 +--- !u!1 &644420371 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 644420372} + - component: {fileID: 644420375} + - component: {fileID: 644420374} + - component: {fileID: 644420373} + m_Layer: 5 + m_Name: Constants_LogTest + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &644420372 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 644420371} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1810866622} + m_Father: {fileID: 1970463316} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: -51.7, y: 0} + m_SizeDelta: {x: 100, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &644420373 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 644420371} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1392445389, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 644420374} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 1970463317} + m_MethodName: LogTest + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0, + Culture=neutral, PublicKeyToken=null +--- !u!114 &644420374 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 644420371} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!222 &644420375 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 644420371} + m_CullTransparentMesh: 0 --- !u!1 &657236372 GameObject: m_ObjectHideFlags: 0 @@ -3340,6 +3588,135 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1123157563} m_CullTransparentMesh: 0 +--- !u!1001 &1164197553 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 1970463316} + m_Modifications: + - target: {fileID: 6101637671845785379, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_Name + value: TEXTPREFAB + objectReference: {fileID: 0} + - target: {fileID: 6101637671845785379, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_LocalRotation.y + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_RootOrder + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_AnchoredPosition.x + value: 83.8 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_AnchoredPosition.y + value: -3.2 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_SizeDelta.x + value: 160 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_SizeDelta.y + value: 30 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_AnchorMin.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_AnchorMin.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_AnchorMax.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_AnchorMax.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_Pivot.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_Pivot.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 873434211562065042, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_Text + value: Constants + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 2e8e46b2076394b499aaa4d49bc28218, type: 3} --- !u!1001 &1215308964 PrefabInstance: m_ObjectHideFlags: 0 @@ -4209,6 +4586,85 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1749062262} m_CullTransparentMesh: 0 +--- !u!1 &1810866621 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1810866622} + - component: {fileID: 1810866624} + - component: {fileID: 1810866623} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1810866622 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1810866621} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 644420372} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1810866623 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1810866621} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Logging Test +--- !u!222 &1810866624 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1810866621} + m_CullTransparentMesh: 0 --- !u!1 &1847045797 GameObject: m_ObjectHideFlags: 0 @@ -4338,6 +4794,30 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1847045797} m_CullTransparentMesh: 0 +--- !u!1 &1970463315 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 1290408108987661695, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + m_PrefabInstance: {fileID: 161055706} + m_PrefabAsset: {fileID: 0} +--- !u!224 &1970463316 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + m_PrefabInstance: {fileID: 161055706} + m_PrefabAsset: {fileID: 0} +--- !u!114 &1970463317 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1970463315} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: afb9aa56d4d0270458c55b0c7cec3409, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &2013164477 GameObject: m_ObjectHideFlags: 0 @@ -4433,6 +4913,7 @@ RectTransform: - {fileID: 2122928410} - {fileID: 546077433} - {fileID: 1375305754} + - {fileID: 1970463316} m_Father: {fileID: 0} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/MDMulti/Scripts/Helpers/ConstantsHelper.cs b/Assets/MDMulti/Scripts/Helpers/ConstantsHelper.cs index f0d4014..1acd7b6 100644 --- a/Assets/MDMulti/Scripts/Helpers/ConstantsHelper.cs +++ b/Assets/MDMulti/Scripts/Helpers/ConstantsHelper.cs @@ -5,15 +5,13 @@ namespace MDMulti { public class ConstantsHelper { + /// + /// Get the Constants Object. + /// public static ConstantsObject Get() { string data = Resources.Load("constants").text; return ConstantsObject.FromJson(data); } - - public static void Test() - { - Debug.Log(Get().Lan.Multicast.Address + ":" + Get().Lan.Multicast.Port); - } } } \ No newline at end of file From 384d637df35be0c9726f7edb76d9f06086a674c9 Mon Sep 17 00:00:00 2001 From: James Cahill Date: Sun, 24 Nov 2019 10:21:02 +0000 Subject: [PATCH 13/15] [DebugScene] Add SHA2Test --- Assets/Debug/DebugScene/DebugScene.unity | 481 +++++++++++++++++++++++ Assets/Debug/DebugScene/SHA2.cs | 74 ++++ Assets/Debug/DebugScene/SHA2.cs.meta | 11 + 3 files changed, 566 insertions(+) create mode 100644 Assets/Debug/DebugScene/SHA2.cs create mode 100644 Assets/Debug/DebugScene/SHA2.cs.meta diff --git a/Assets/Debug/DebugScene/DebugScene.unity b/Assets/Debug/DebugScene/DebugScene.unity index d7f05aa..6185b33 100644 --- a/Assets/Debug/DebugScene/DebugScene.unity +++ b/Assets/Debug/DebugScene/DebugScene.unity @@ -2511,6 +2511,135 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 657236372} m_CullTransparentMesh: 0 +--- !u!1001 &669699736 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 1176862476} + m_Modifications: + - target: {fileID: 6101637671845785379, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_Name + value: TEXTPREFAB + objectReference: {fileID: 0} + - target: {fileID: 6101637671845785379, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_LocalRotation.y + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_RootOrder + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_AnchoredPosition.x + value: 80.5 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_AnchoredPosition.y + value: -3.2 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_SizeDelta.x + value: 160 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_SizeDelta.y + value: 30 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_AnchorMin.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_AnchorMin.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_AnchorMax.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_AnchorMax.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_Pivot.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 746092036223162167, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_Pivot.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 873434211562065042, guid: 2e8e46b2076394b499aaa4d49bc28218, + type: 3} + propertyPath: m_Text + value: SHA2 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 2e8e46b2076394b499aaa4d49bc28218, type: 3} --- !u!1 &750983555 GameObject: m_ObjectHideFlags: 0 @@ -3251,6 +3380,125 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1034108690} m_CullTransparentMesh: 0 +--- !u!1001 &1088100995 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 2013164481} + m_Modifications: + - target: {fileID: 1290408108987661695, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_Name + value: SHA2 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_LocalRotation.y + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_RootOrder + value: 6 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_AnchoredPosition.x + value: -24.3 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_AnchoredPosition.y + value: -197.49 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_SizeDelta.x + value: 125 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_SizeDelta.y + value: 50 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_AnchorMin.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_AnchorMin.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_AnchorMax.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_AnchorMax.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_Pivot.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + propertyPath: m_Pivot.y + value: 0.5 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, type: 3} --- !u!1 &1111416823 GameObject: m_ObjectHideFlags: 0 @@ -3717,6 +3965,30 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 2e8e46b2076394b499aaa4d49bc28218, type: 3} +--- !u!1 &1176862475 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 1290408108987661695, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + m_PrefabInstance: {fileID: 1088100995} + m_PrefabAsset: {fileID: 0} +--- !u!224 &1176862476 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 1688249289041980399, guid: ab998dca4e3cb6440bb3fe2a32c8ed82, + type: 3} + m_PrefabInstance: {fileID: 1088100995} + m_PrefabAsset: {fileID: 0} +--- !u!114 &1176862477 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1176862475} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2faa3740cc66fe64da85c9e6e292643a, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1001 &1215308964 PrefabInstance: m_ObjectHideFlags: 0 @@ -4507,6 +4779,135 @@ Transform: m_Father: {fileID: 2122928410} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1712182060 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1712182061} + - component: {fileID: 1712182064} + - component: {fileID: 1712182063} + - component: {fileID: 1712182062} + m_Layer: 5 + m_Name: SHA2_TEST + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1712182061 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1712182060} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1797689698} + m_Father: {fileID: 1176862476} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: -28, y: 0} + m_SizeDelta: {x: 50, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1712182062 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1712182060} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1392445389, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 1712182063} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 1176862477} + m_MethodName: Test + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0, + Culture=neutral, PublicKeyToken=null +--- !u!114 &1712182063 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1712182060} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!222 &1712182064 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1712182060} + m_CullTransparentMesh: 0 --- !u!1 &1749062262 GameObject: m_ObjectHideFlags: 0 @@ -4586,6 +4987,85 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1749062262} m_CullTransparentMesh: 0 +--- !u!1 &1797689697 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1797689698} + - component: {fileID: 1797689700} + - component: {fileID: 1797689699} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1797689698 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1797689697} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1712182061} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1797689699 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1797689697} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Test +--- !u!222 &1797689700 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1797689697} + m_CullTransparentMesh: 0 --- !u!1 &1810866621 GameObject: m_ObjectHideFlags: 0 @@ -4914,6 +5394,7 @@ RectTransform: - {fileID: 546077433} - {fileID: 1375305754} - {fileID: 1970463316} + - {fileID: 1176862476} m_Father: {fileID: 0} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Debug/DebugScene/SHA2.cs b/Assets/Debug/DebugScene/SHA2.cs new file mode 100644 index 0000000..5a38f02 --- /dev/null +++ b/Assets/Debug/DebugScene/SHA2.cs @@ -0,0 +1,74 @@ +using MDMulti.Net; +using System; +using System.Text; +using UnityEngine; + +namespace MDMulti_DEBUG.DebugScene +{ + public class SHA2 : MonoBehaviour + { + string dataToHash = "This is a SHA256 test."; + byte[] dataToHashB { get { return Encoding.UTF8.GetBytes(dataToHash); } } + + string expectedHash = "4816482f8b4149f687a1a33d61a0de6b611364ec0fb7adffa59ff2af672f7232".ToUpper(); + + public void Test() + { + Debug.LogWarning("----- Starting SHA2 Test -----"); + + + // Test Phase 1: Creation and validation + Debug.LogWarning("----- PHASE 1: CREATION + VALIDATION -----"); + + Debug.Log("Hashing string '" + dataToHash + "'"); + + byte[] combined = Core.GenerateAndAddHash(dataToHashB); + + string gotHash = Core.GetHash(combined); + + Debug.Log("Got hash " + gotHash); + Debug.Log("Expected hash " + expectedHash); + + if (gotHash == expectedHash) + { + Debug.Log("Hashes match!"); + } else + { + Debug.LogError("Hashes do not match!"); + } + + + // Test Phase 2: Extraction + Debug.LogWarning("----- PHASE 2: EXTRACTION -----"); + + Debug.Log("Extracting string and hash..."); + + Tuple split = Core.SplitHashAndMessage(combined); + + string extractedMessage = Encoding.UTF8.GetString(split.Item1); + + Debug.Log("Extracted message '" + extractedMessage + "'"); + Debug.Log("Extracted hash " + split.Item2); + + if (dataToHash == extractedMessage) + { + Debug.Log("Messages match!"); + } else + { + Debug.LogError("Extracted message did not match original!"); + } + + if (expectedHash == split.Item2) + { + Debug.Log("Hashes match!"); + } else + { + Debug.LogError("Extracted hash did not match original!"); + } + + + // End of test + Debug.LogWarning("----- SHA2 Test Finished! -----\nPlease check logs for possible errors."); + } + } +} \ No newline at end of file diff --git a/Assets/Debug/DebugScene/SHA2.cs.meta b/Assets/Debug/DebugScene/SHA2.cs.meta new file mode 100644 index 0000000..0e192fa --- /dev/null +++ b/Assets/Debug/DebugScene/SHA2.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2faa3740cc66fe64da85c9e6e292643a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From aa8ba6f6dd6c327dc739d929ad2cfccd0c7c4286 Mon Sep 17 00:00:00 2001 From: James Cahill Date: Sun, 24 Nov 2019 10:23:26 +0000 Subject: [PATCH 14/15] [DebugScene SHA2] Make constants private readonly --- Assets/Debug/DebugScene/SHA2.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Assets/Debug/DebugScene/SHA2.cs b/Assets/Debug/DebugScene/SHA2.cs index 5a38f02..8b5beb4 100644 --- a/Assets/Debug/DebugScene/SHA2.cs +++ b/Assets/Debug/DebugScene/SHA2.cs @@ -7,10 +7,11 @@ namespace MDMulti_DEBUG.DebugScene { public class SHA2 : MonoBehaviour { - string dataToHash = "This is a SHA256 test."; - byte[] dataToHashB { get { return Encoding.UTF8.GetBytes(dataToHash); } } + private readonly string dataToHash = "This is a SHA256 test."; + // No point adding readonly here as there is only a getter anyways. + private byte[] dataToHashB { get { return Encoding.UTF8.GetBytes(dataToHash); } } - string expectedHash = "4816482f8b4149f687a1a33d61a0de6b611364ec0fb7adffa59ff2af672f7232".ToUpper(); + private readonly string expectedHash = "4816482f8b4149f687a1a33d61a0de6b611364ec0fb7adffa59ff2af672f7232".ToUpper(); public void Test() { From 4911d7e5e1ba2631245cbdd606e8d0fd3a5ba349 Mon Sep 17 00:00:00 2001 From: James Cahill Date: Sun, 24 Nov 2019 10:39:34 +0000 Subject: [PATCH 15/15] misc. comment cleanup --- Assets/Debug/DebugScene/Latest.cs | 21 +++------------------ Assets/MDMulti/Scripts/KeyDB.cs | 3 +-- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/Assets/Debug/DebugScene/Latest.cs b/Assets/Debug/DebugScene/Latest.cs index 060814b..686a458 100644 --- a/Assets/Debug/DebugScene/Latest.cs +++ b/Assets/Debug/DebugScene/Latest.cs @@ -1,5 +1,4 @@ -using System.Text; -using UnityEngine; +using UnityEngine; namespace MDMulti_DEBUG.DebugScene { @@ -8,34 +7,20 @@ public class Latest : MonoBehaviour public async void Latest1() { Debug.Log("L"); - //Debug.Log(MDMulti.SHA2Helper.ComputeHash(new byte[0])); - //Debug.Log(MDMulti.SHA2Helper.ComputeHashStr("")); - //MDMulti.ConstantsHelper.Test(); + // KEYDB Testing | AddIfNotPresent - - // KEYDB Testing MDMulti.PeerDB.KeyFile s = await MDMulti.PeerDB.GetObject(); - //s.keys.Add(new MDMulti.PeerDB.KeyItem(await MDMulti.CertHelper.GetCertificateFromFile("p4.crt"))); s.AddX509IfNotPresent(await MDMulti.CertHelper.GetCertificateFromFile("p4.crt")); s.SaveToFile(); } public async void Latest2() { - /* Debug.Log("L2"); - byte[] s = MDMulti.Net.Core.GenerateAndAddHash(Encoding.UTF8.GetBytes("This is a SHA256 function.")); - Debug.Log(MDMulti.Net.Core.GetHash(s)); - Debug.Log("3"); - byte[] s3 = MDMulti.Net.Core.GenerateAndAddHash(Encoding.UTF8.GetBytes("This is a SHA256 function.")); - var ss = MDMulti.Net.Core.SplitHashAndMessage(s3); - - Debug.Log("MSG: " + Encoding.UTF8.GetString(ss.Item1)); - Debug.Log("HASH: " + ss.Item2); - */ + // KEYDB Testing var kf = await MDMulti.PeerDB.GetObject(); diff --git a/Assets/MDMulti/Scripts/KeyDB.cs b/Assets/MDMulti/Scripts/KeyDB.cs index f8f7eff..7ef7eb6 100644 --- a/Assets/MDMulti/Scripts/KeyDB.cs +++ b/Assets/MDMulti/Scripts/KeyDB.cs @@ -21,9 +21,8 @@ private static Constants.PeerdbFile GetConstants() } /// - /// Create or load an object + /// Create or load an object. /// - /// TODO: Extend FileExists to IsFileAvailable public static async Task GetObject() { if (!await StorageHelper.FileExistsAndIsJson(GetConstants().Name))