secure_compressor 1.0.10
secure_compressor: ^1.0.10 copied to clipboard
This is a Dart package that provides utilities for securely encrypting, decrypting, compressing, and decompressing string data using AES encryption and gzip compression
secure-compressor #
secure_compressor
is a Dart package that provides utilities for securely encrypting, decrypting, compressing, and decompressing string data using AES encryption and gzip compression.
Features #
- Encrypt and decrypt string data using AES encryption.
- Compress and decompress string data using gzip.
- Combine encryption and compression for secure and efficient data storage and transmission.
- Save encrypted and compressed data to local storage.
- Share encrypted and compressed data to media platform device (WA, email, etc).
Installation #
Add the following to your pubspec.yaml
file:
dependencies:
secure_compressor: <Latest-Version>
Then, run flutter pub get to fetch the package.
Usages #
::: Notes :::
- keyString must be 32 character
- Initialization Vector (IV) [ivString] must be 16 character
Encrypt #
Encrypt a string using AES encryption:
final result = await SecureCompressor.encrypt(data, keyString, ivString: ivString);
Compress and then encrypt a string:
final result = await SecureCompressor.compressAndEncrypt(data, keyString, ivString: ivString);
Decrypt #
Decrypt an AES encrypted string:
final result = SecureCompressor.decrypt(encryptedData, keyString, ivString: ivString);
Decrypt and then uncompress a string:
final result = SecureCompressor.uncompressAndDecrypt(compressedAndEncryptedData, keyString, ivString: ivString);
Save Data to Local Storage #
Save data to a local file:
SecureCompressor.saveDataToLocal(fileName, data);
Share Data to Media Platform Device (WA, email, etc) #
Share data to a media platform device:
SecureCompressor.shareFile(fileName, data);
Generate Unix Key #
If you wanna generate unix key, you can use this function. NOTE: NEVER USE THIS FUNCTION TO ENCRYPT OR DECRYPT FROM OTHER DEVICE
await SecureCompressor.getUnixId()
Save Primitif Data Type into Local Storage #
Save primitif data type as string, boolean, int, and double into local storage using GetStorage.
Initializes the storage helper with the given parameters first befor run the app:
await StorageHelper.initialize(
'YOUR_STORAGE_NAME',
isEncryptKeyAndValue: true, // Default true
encryptionKey: "YOUR_ENCRYPTION_KEY_MUST_BE_32_CHAR", // If null, will use unix id from devices used
isKeyEncrypted: false, // Default false
);
StorageHelper.saveString('test_key', 'test_value');
final savedData = StorageHelper.getString('test_key');