Crypt Class
The Crypt
class is a part of the Chase CommonLib library developed by LFInteractive LLC. This class is designed for encrypting and decrypting strings and files using the AES encryption algorithm. It provides methods to encrypt and decrypt data and allows you to specify a custom salt for added security.
Class Overview
Namespace
License
The Crypt
class is licensed under the GPL-3.0 license.
Summary
A class for encrypting and decrypting strings and files using the AES encryption algorithm.
Constructor
Crypt()
Crypt()
Creates a new instance of the Crypt
class with a random salt based on the current machine.
Crypt(string salt)
Crypt(string salt)
Creates a new instance of the Crypt
class with the specified salt.
salt
: A custom salt value used for encryption and decryption.
Properties
Salt
Salt
Gets or sets the salt used for encryption and decryption.
Methods
Encrypt(string text)
Encrypt(string text)
Encrypts the specified text using AES encryption.
text
: The text to be encrypted.
Returns the encrypted text as a Base64-encoded string.
Encrypt(string path, string output)
Encrypt(string path, string output)
Encrypts the content of a file and writes the encrypted data to an output file.
path
: The path to the input file.output
: The path to the output file where the encrypted data will be written.
Decrypt(string path, string output)
Decrypt(string path, string output)
Decrypts the content of a file and writes the decrypted data to an output file.
path
: The path to the input file containing encrypted data.output
: The path to the output file where the decrypted data will be written.
Decrypt(string text)
Decrypt(string text)
Decrypts the specified Base64-encoded text using AES decryption.
text
: The Base64-encoded text to be decrypted.
Returns the decrypted text.
Private Methods
GetSaltBytes()
GetSaltBytes()
Gets the salt bytes derived from the Salt
property.
Examples
Example 1: Encrypting and Decrypting Text
Example 2: Encrypting and Decrypting Files
This documentation provides an overview of the Crypt
class, its constructor, properties, methods, and includes example code demonstrating how to use it for text and file encryption and decryption.
Last updated
Was this helpful?