From 6d03effbcfa818dc571b230bd2294aaf7c9f3a1e Mon Sep 17 00:00:00 2001 From: JosepeDev Date: Thu, 5 Nov 2020 19:38:24 +0200 Subject: [PATCH] Deleted the generic classes --- Files/EncryptedInt08.cs | 14 -- ...\342\200\217\342\200\217EncryptedInt16.cs" | 14 -- ...\342\200\217\342\200\217EncryptedInt32.cs" | 14 -- ...\342\200\217\342\200\217EncryptedInt64.cs" | 14 -- ...42\200\217\342\200\217EncryptedInteger.cs" | 129 ------------------ 5 files changed, 185 deletions(-) delete mode 100644 Files/EncryptedInt08.cs delete mode 100644 "Files/\342\200\217\342\200\217EncryptedInt16.cs" delete mode 100644 "Files/\342\200\217\342\200\217\342\200\217\342\200\217EncryptedInt32.cs" delete mode 100644 "Files/\342\200\217\342\200\217\342\200\217\342\200\217EncryptedInt64.cs" delete mode 100644 "Files/\342\200\217\342\200\217\342\200\217\342\200\217EncryptedInteger.cs" diff --git a/Files/EncryptedInt08.cs b/Files/EncryptedInt08.cs deleted file mode 100644 index 4253bd6..0000000 --- a/Files/EncryptedInt08.cs +++ /dev/null @@ -1,14 +0,0 @@ -public class EncryptedInt08 : EncryptedInteger -{ - /// 8-bit integer value range: -128 to 127 - - #region Constructors - - public EncryptedInt08(sbyte value) - : base(value) { } - - public EncryptedInt08() - : this(0) { } - - #endregion -} \ No newline at end of file diff --git "a/Files/\342\200\217\342\200\217EncryptedInt16.cs" "b/Files/\342\200\217\342\200\217EncryptedInt16.cs" deleted file mode 100644 index 204ff91..0000000 --- "a/Files/\342\200\217\342\200\217EncryptedInt16.cs" +++ /dev/null @@ -1,14 +0,0 @@ -public class EncryptedInt16 : EncryptedInteger -{ - /// 16-bit integer value range: -32,768 to 32,767 - - #region Constructors - - public EncryptedInt16(short value) - : base(value) { } - - public EncryptedInt16() - : this(0) { } - - #endregion -} \ No newline at end of file diff --git "a/Files/\342\200\217\342\200\217\342\200\217\342\200\217EncryptedInt32.cs" "b/Files/\342\200\217\342\200\217\342\200\217\342\200\217EncryptedInt32.cs" deleted file mode 100644 index 168cf3b..0000000 --- "a/Files/\342\200\217\342\200\217\342\200\217\342\200\217EncryptedInt32.cs" +++ /dev/null @@ -1,14 +0,0 @@ -public class EncryptedInt32 : EncryptedInteger -{ - /// 32-bit integer value range: -2,147,483,648 to 2,147,483,647 - - #region Constructors - - public EncryptedInt32(int value) - : base(value) { } - - public EncryptedInt32() - : this(0) { } - - #endregion -} \ No newline at end of file diff --git "a/Files/\342\200\217\342\200\217\342\200\217\342\200\217EncryptedInt64.cs" "b/Files/\342\200\217\342\200\217\342\200\217\342\200\217EncryptedInt64.cs" deleted file mode 100644 index 2519c42..0000000 --- "a/Files/\342\200\217\342\200\217\342\200\217\342\200\217EncryptedInt64.cs" +++ /dev/null @@ -1,14 +0,0 @@ -public class EncryptedInt64 : EncryptedInteger -{ - /// 64-bit integer value range: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 - - #region Constructors - - public EncryptedInt64(long value) - : base(value) { } - - public EncryptedInt64() - : this(0) { } - - #endregion -} \ No newline at end of file diff --git "a/Files/\342\200\217\342\200\217\342\200\217\342\200\217EncryptedInteger.cs" "b/Files/\342\200\217\342\200\217\342\200\217\342\200\217EncryptedInteger.cs" deleted file mode 100644 index b2ada29..0000000 --- "a/Files/\342\200\217\342\200\217\342\200\217\342\200\217EncryptedInteger.cs" +++ /dev/null @@ -1,129 +0,0 @@ -using System; - -public class EncryptedInteger - where TDecrypted : IComparable, IConvertible - where TEncrypted : IComparable, IConvertible -{ - /// A generic class for storing every type of 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 } - /// It is recommended to reset them everytime the program starts. - /// - /// Wiki page: https://github.com/JosepeDev/Variable-Encryption/wiki - /// Examples and tutorial: https://github.com/JosepeDev/Variable-Encryption/wiki/Examples-&-Tutorial - /// - /// ---- Generic setup: - /// - /// TDecrypted should be an integer: - /// sbyte, short, int, long - /// - /// TEncrypted shoud be a floating-point number: - /// float, double, decimal - /// - /// ---- Properties: - /// - /// Value - Returns the decrypted value of the stored int. It'll work exactly as an int. - /// - /// ---- Methods: - /// - /// ResetEncryptionKeys() - Changes the random values that effect the stored int while keeping its value - /// ToString() - Returns the value of the stored int as a string. - - #region Content - - #region Variables and Properties - - // The encryption values - dynamic encryptionKey1; - dynamic encryptionKey2; - - // The encrypted value stored in memory - private TEncrypted encryptedValue; - - // The decrypted value - public TDecrypted Value - { - set - { - dynamic val = value; - encryptedValue = encrypt(val); - } - get - { - dynamic encryptedVal = encryptedValue; - return (TDecrypted)Math.Round(decrypt(encryptedVal)); - } - } - - #endregion - - #region Constructors - - // Constractors - public EncryptedInteger(TDecrypted value) - { - dynamic val = value; - SetEncryptionKeys(); - encryptedValue = encrypt(val); - } - - public EncryptedInteger() - { - dynamic val = 0; - SetEncryptionKeys(); - encryptedValue = encrypt(val); - } - - #endregion - - #region Methods - - // Takes a given value and returns it encrypted - private TEncrypted encrypt(TEncrypted value) - { - TEncrypted valueToReturn = value; - valueToReturn += encryptionKey1; - valueToReturn *= encryptionKey2; - return valueToReturn; - } - - // Takes an encrypted value and returns it decrypted - private TEncrypted decrypt(TEncrypted value) - { - TEncrypted valueToReturn = value; - valueToReturn /= encryptionKey2; - valueToReturn -= encryptionKey1; - return valueToReturn; - } - - // Setting the encryption keys to a new random values - private void SetEncryptionKeys() - { - dynamic randomVar1 = EncryptionTools.RandomNumberDouble(); - dynamic randomVar2 = EncryptionTools.RandomNumberDouble(); - encryptionKey1 = (TEncrypted)randomVar1; - encryptionKey2 = (TEncrypted)randomVar2; - } - - // Resets the encryption keys and keeps the stored values - public void ResetEncryptionKeys() - { - // keep and decrypt the current value - TDecrypted decryptedValue = Value; - - // set a new values to the encryption keys - SetEncryptionKeys(); - - // set and encrypt the value back with the new keys - Value = decryptedValue; - } - - // Returns the stored value as a string - public string ToString() - { - return Value.ToString(); - } - - #endregion - - #endregion -} \ No newline at end of file