Simple Encryption/Decryption
Crypt()
Syntax: _Crypt(str, k, inv)
Purpose: Performs basic encryption and decryption using a provided key.
Parameters:
str: The string to encrypt or decrypt.
k: An array containing the encryption key values.
inv: (Optional) True for decryption, false for encryption (default).
Base64 Encoding/Decoding
Dec_base64()
Syntax: _Dec_base64(binary_data)
Purpose: Decodes Base64 encoded text or binary data back to its original form.
Enc_base64()
Syntax: _Enc_base64(binary_data)
Purpose: Encodes plain text or binary data into the Base64 format. This is often used for data portability and safe transmission.
Mapping-Based Encryption/Decryption
Decrypt()
Syntax: _Decrypt(value_to_decrypt, encrypted_values, decrypted_values)
Purpose: Decrypts a value by mapping it from a list of encrypted values to a corresponding list of decrypted values.
Multi_Decrypt()
Syntax: _Multi_Decrypt(value_to_decrypt, encrypted_values, decrypted_values)
Purpose:
Similar to Decrypt
,
but replaces all
matching encrypted values within the input string.
Hashing
Sha1()
Syntax: _Sha1(string)
Purpose: Applies the SHA1 cryptographic hash function to a string, generating a secure fingerprint of the input data.
Sha256()
Syntax: _Sha256(string)
Purpose: Applies the SHA256 hash function (even more secure than SHA1).
Advanced Encryption (dDen, dEnc)
dDen()
Syntax: _dDen(str, key1, key2)
Purpose: Decrypts data using a more complex method, requiring two different keys.
dEnc()
Syntax: _dEnc(str, key1, key2)
Purpose:
The corresponding encryption function for dDen
.
Key Points
Security
Levels:
The Crypt
function provides basic obfuscation. For more robust security,
consider Sha1
,
Sha256
,
or the dDen
/dEnc
methods.
Base64: This is primarily for encoding data into a transmittable format, not strong encryption.
Key Management: Protecting your encryption keys is crucial for maintaining the security of your encrypted data!
Example: Combining Techniques
-- Securely storing a password
originalPassword =
"MySecret123"
hashedPassword = _Sha256(originalPassword)
storedData = _dEnc(hashedPassword,
"key1"
,
"key2"
)
-- Later, when verifying login
enteredPassword =
"...."
-- Get this from user input
hashedInput = _Sha256(enteredPassword)
decryptedHash = _dDen(storedData,
"key1"
,
"key2"
)
if
hashedInput == decryptedHash
then
-- Login successful
end