diff --git a/Files/eint.cs b/Files/EncInt.cs similarity index 55% rename from Files/eint.cs rename to Files/EncInt.cs index b34297c..56ef365 100644 --- a/Files/eint.cs +++ b/Files/EncInt.cs @@ -1,6 +1,6 @@ using System; -public struct eint +public struct EncInt { /// A struct for storing a 32-bit integer while efficiently keeping it encrypted in the memory. /// In the memory it is saved as a floating-point number that is affected by random values. { encryptionKey1 & encryptionKey2 } @@ -37,7 +37,7 @@ private double Value #region Constructors - private eint(int value) + private EncInt(int value) { // set default values encryptionKey1 = 0; @@ -87,7 +87,7 @@ public override string ToString() // Not recommended to use public override bool Equals(object obj) { - return obj is eint eint && + return obj is EncInt eint && (int)Value == (int)eint.Value; } public override int GetHashCode() @@ -100,32 +100,32 @@ public override int GetHashCode() #region Operators Overloading /// + - * / % - public static eint operator +(eint eint1, eint eint2) => new eint((int)(eint1.Value + eint2.Value)); - public static eint operator -(eint eint1, eint eint2) => new eint((int)(eint1.Value - eint2.Value)); - public static eint operator *(eint eint1, eint eint2) => new eint((int)(eint1.Value * eint2.Value)); - public static eint operator /(eint eint1, eint eint2) => new eint((int)(eint1.Value / eint2.Value)); - public static eint operator %(eint eint1, eint eint2) => new eint((int)(eint1.Value % eint2.Value)); - - public static int operator +(eint eint1, int eint2) => (int)eint1.Value + eint2; - public static int operator -(eint eint1, int eint2) => (int)eint1.Value - eint2; - public static int operator *(eint eint1, int eint2) => (int)eint1.Value * eint2; - public static int operator /(eint eint1, int eint2) => (int)eint1.Value / eint2; - public static int operator %(eint eint1, int eint2) => (int)eint1.Value % eint2; + public static EncInt operator +(EncInt eint1, EncInt eint2) => new EncInt((int)(eint1.Value + eint2.Value)); + public static EncInt operator -(EncInt eint1, EncInt eint2) => new EncInt((int)(eint1.Value - eint2.Value)); + public static EncInt operator *(EncInt eint1, EncInt eint2) => new EncInt((int)(eint1.Value * eint2.Value)); + public static EncInt operator /(EncInt eint1, EncInt eint2) => new EncInt((int)(eint1.Value / eint2.Value)); + public static EncInt operator %(EncInt eint1, EncInt eint2) => new EncInt((int)(eint1.Value % eint2.Value)); + + public static int operator +(EncInt eint1, int eint2) => (int)eint1.Value + eint2; + public static int operator -(EncInt eint1, int eint2) => (int)eint1.Value - eint2; + public static int operator *(EncInt eint1, int eint2) => (int)eint1.Value * eint2; + public static int operator /(EncInt eint1, int eint2) => (int)eint1.Value / eint2; + public static int operator %(EncInt eint1, int eint2) => (int)eint1.Value % eint2; /// == != < > - public static bool operator ==(eint eint1, int eint2) => (int)eint1.Value == eint2; - public static bool operator !=(eint eint1, int eint2) => (int)eint1.Value != eint2; - public static bool operator >(eint eint1, int eint2) => (int)eint1.Value > eint2; - public static bool operator <(eint eint1, int eint2) => (int)eint1.Value < eint2; + public static bool operator ==(EncInt eint1, int eint2) => (int)eint1.Value == eint2; + public static bool operator !=(EncInt eint1, int eint2) => (int)eint1.Value != eint2; + public static bool operator >(EncInt eint1, int eint2) => (int)eint1.Value > eint2; + public static bool operator <(EncInt eint1, int eint2) => (int)eint1.Value < eint2; - public static bool operator ==(eint eint1, eint eint2) => (int)eint1.Value == (int)eint2.Value; - public static bool operator !=(eint eint1, eint eint2) => (int)eint1.Value != (int)eint2.Value; - public static bool operator <(eint eint1, eint eint2) => (int)eint1.Value < (int)eint2.Value; - public static bool operator >(eint eint1, eint eint2) => (int)eint1.Value > (int)eint2.Value; + public static bool operator ==(EncInt eint1, EncInt eint2) => (int)eint1.Value == (int)eint2.Value; + public static bool operator !=(EncInt eint1, EncInt eint2) => (int)eint1.Value != (int)eint2.Value; + public static bool operator <(EncInt eint1, EncInt eint2) => (int)eint1.Value < (int)eint2.Value; + public static bool operator >(EncInt eint1, EncInt eint2) => (int)eint1.Value > (int)eint2.Value; /// assign - public static implicit operator eint(int value) => new eint(value); - public static implicit operator int(eint eint1) => (int)eint1.Value; + public static implicit operator EncInt(int value) => new EncInt(value); + public static implicit operator int(EncInt eint1) => (int)eint1.Value; #endregion diff --git a/Files/elong.cs b/Files/EncLong.cs similarity index 54% rename from Files/elong.cs rename to Files/EncLong.cs index c876adb..3ced484 100644 --- a/Files/elong.cs +++ b/Files/EncLong.cs @@ -1,6 +1,6 @@ using System; -public struct elong +public struct EncLong { /// A struct for storing a 64-bit integer while efficiently keeping it encrypted in the memory. /// In the memory it is saved as a floating-point number that is affected by random values. { encryptionKey1 & encryptionKey2 } @@ -37,7 +37,7 @@ private decimal Value #region Constructors - private elong(long value) + private EncLong(long value) { // set default values encryptionKey1 = 0; @@ -87,7 +87,7 @@ public override string ToString() // Not recommended to use public override bool Equals(object obj) { - return obj is elong eint && + return obj is EncLong eint && (long)Value == (long)eint.Value; } public override int GetHashCode() @@ -100,32 +100,32 @@ public override int GetHashCode() #region Operators Overloading /// + - * / % - public static elong operator +(elong eint1, elong eint2) => new elong((long)(eint1.Value + eint2.Value)); - public static elong operator -(elong eint1, elong eint2) => new elong((long)(eint1.Value - eint2.Value)); - public static elong operator *(elong eint1, elong eint2) => new elong((long)(eint1.Value * eint2.Value)); - public static elong operator /(elong eint1, elong eint2) => new elong((long)(eint1.Value / eint2.Value)); - public static elong operator %(elong eint1, elong eint2) => new elong((long)(eint1.Value % eint2.Value)); - - public static long operator +(elong eint1, long eint2) => (long)eint1.Value + eint2; - public static long operator -(elong eint1, long eint2) => (long)eint1.Value - eint2; - public static long operator *(elong eint1, long eint2) => (long)eint1.Value * eint2; - public static long operator /(elong eint1, long eint2) => (long)eint1.Value / eint2; - public static long operator %(elong eint1, long eint2) => (long)eint1.Value % eint2; + public static EncLong operator +(EncLong eint1, EncLong eint2) => new EncLong((long)(eint1.Value + eint2.Value)); + public static EncLong operator -(EncLong eint1, EncLong eint2) => new EncLong((long)(eint1.Value - eint2.Value)); + public static EncLong operator *(EncLong eint1, EncLong eint2) => new EncLong((long)(eint1.Value * eint2.Value)); + public static EncLong operator /(EncLong eint1, EncLong eint2) => new EncLong((long)(eint1.Value / eint2.Value)); + public static EncLong operator %(EncLong eint1, EncLong eint2) => new EncLong((long)(eint1.Value % eint2.Value)); + + public static long operator +(EncLong eint1, long eint2) => (long)eint1.Value + eint2; + public static long operator -(EncLong eint1, long eint2) => (long)eint1.Value - eint2; + public static long operator *(EncLong eint1, long eint2) => (long)eint1.Value * eint2; + public static long operator /(EncLong eint1, long eint2) => (long)eint1.Value / eint2; + public static long operator %(EncLong eint1, long eint2) => (long)eint1.Value % eint2; /// == != < > - public static bool operator ==(elong eint1, long eint2) => (long)eint1.Value == eint2; - public static bool operator !=(elong eint1, long eint2) => (long)eint1.Value != eint2; - public static bool operator >(elong eint1, long eint2) => (long)eint1.Value > eint2; - public static bool operator <(elong eint1, long eint2) => (long)eint1.Value < eint2; + public static bool operator ==(EncLong eint1, long eint2) => (long)eint1.Value == eint2; + public static bool operator !=(EncLong eint1, long eint2) => (long)eint1.Value != eint2; + public static bool operator >(EncLong eint1, long eint2) => (long)eint1.Value > eint2; + public static bool operator <(EncLong eint1, long eint2) => (long)eint1.Value < eint2; - public static bool operator ==(elong eint1, elong eint2) => (long)eint1.Value == (long)eint2.Value; - public static bool operator !=(elong eint1, elong eint2) => (long)eint1.Value != (long)eint2.Value; - public static bool operator <(elong eint1, elong eint2) => (long)eint1.Value < (long)eint2.Value; - public static bool operator >(elong eint1, elong eint2) => (long)eint1.Value > (long)eint2.Value; + public static bool operator ==(EncLong eint1, EncLong eint2) => (long)eint1.Value == (long)eint2.Value; + public static bool operator !=(EncLong eint1, EncLong eint2) => (long)eint1.Value != (long)eint2.Value; + public static bool operator <(EncLong eint1, EncLong eint2) => (long)eint1.Value < (long)eint2.Value; + public static bool operator >(EncLong eint1, EncLong eint2) => (long)eint1.Value > (long)eint2.Value; /// assign - public static implicit operator elong(long value) => new elong(value); - public static implicit operator long(elong eint1) => (long)eint1.Value; + public static implicit operator EncLong(long value) => new EncLong(value); + public static implicit operator long(EncLong eint1) => (long)eint1.Value; #endregion