encryptorClass
Template class for encrypting and decrypting values. More...
Public Functions
Type | Name |
---|---|
constexpr T | encrypt (const T c, T Key, size_t Idx) noexcept |
T | decrypt (const T c, T Key, size_t Idx) noexcept |
Detailed Description
The encryptor
class provides a secure and robust mechanism for encrypting and decrypting values of type T
. This class utilizes a combination of XOR operations, key-based transformations, and additional obfuscation techniques to protect data from unauthorized access or tampering.
The encryption process not only XORs the value with a key but also applies several complex transformations, including bit rotations and virtual machine-based callbacks, to enhance security. Similarly, the decryption process reverses these transformations to recover the original value.
The class is particularly useful in scenarios where data needs to be stored or transmitted securely, such as in cryptographic systems, secure communications, or protected storage.
Template Parameters
T
: The type of the values to be encrypted and decrypted. The typeT
must support bitwise operations and conversions to and fromuint64_t
.
Public Functions
constexpr T encrypt (const T c, T Key, size_t Idx) noexcept
Encrypts a given value with a key.
Definition
static constexpr T
Detailed Description
This method performs a highly secure encryption process on the provided value c
using the specified key Key
and an index Idx
. The encryption involves:
Callback Execution : The value is first passed through a callback function, selected based on the index, which applies an initial transformation.
XOR with Key : The transformed value is XORed with a further modified version of the key, which is either rotated left or right depending on the index.
Final Transformation : The result is then subjected to another bit rotation, adding a final layer of obfuscation.
These steps ensure that the encrypted value is not only difficult to reverse-engineer but also highly resistant to common cryptographic attacks.
Parameters
c
: The value to be encrypted. This is the original data that needs to be protected.Key
: The encryption key, which is used to generate the transformations and XOR operations.Idx
: An index value that influences the transformations applied during encryption. It adds variability and complexity to the encryption process.
Returns
The encrypted value. This value is the result of the encryption process and can be securely stored or transmitted.
T decrypt (const T c, T Key, size_t Idx) noexcept
Decrypts a given value with a key.
Definition
static T
Detailed Description
This method reverses the encryption process applied by the encrypt
method. It takes the encrypted value c
, the key Key
, and the index Idx
used during encryption, and applies the inverse operations to recover the original value. The decryption process involves:
Inverse Final Transformation : The encrypted value is first subjected to the inverse of the final transformation applied during encryption (bit rotation).
XOR with Key : The result is then XORed with the modified key, reversing the XOR operation applied during encryption.
Callback Execution : Finally, the value is passed through the decryption callback function to complete the recovery of the original data.
This process ensures that the original value is accurately restored, provided the correct key and index are used.
Parameters
c
: The encrypted value to be decrypted. This is the data that needs to be converted back to its original form.Key
: The decryption key, which must be the same as the key used during the encryption process.Idx
: An index value that was used during the encryption process. It must match the index used for encryption to ensure correct decryption.
Returns
The decrypted value. This is the original value that was encrypted, now restored to its original state.