encrypt_env 3.2.0
encrypt_env: ^3.2.0 copied to clipboard
Generate obfuscated or encrypted Dart files from YAML/JSON configuration. Protect sensitive data in Flutter/Dart apps with multi-layer XOR obfuscation or AES-256 encryption.
Changelog #
3.2.0 - 2026-04-16 #
Added #
- Warning when generating AES test files alerting that the embedded key must not be committed to public repositories
- Dartdoc on the library directive (resolves pub.dev
Documentationscoring)
Changed #
AesStrategyuses the typedFortis.aes().gcm().cipher(...)shortcut;_cipheris now declared asAesAuthCipher(the statically-typed AEAD variant from fortis 0.2.0)- Generator runs
dart formaton the main output file too — previously only the test file was formatted Random.secure()is reused across encoding operations instead of being re-instantiated per value- Command error handlers now log stack traces via
_logger.detail(...)— visible under--verbose GenerateCommandcatchesFortisConfigExceptionseparately, returningExitCode.usage(64) with a clearer message for invalid AES keys
Fixed #
toSnakeCase()now inserts_between camelCase/PascalCase boundaries. YAML keys likehelloWorldproducehello_world(with-s sc) orHELLO_WORLD(with-s ssc), instead of the previoushelloworld/HELLOWORLD- Test generator now escapes
$,\,',\n,\r,\tin string values — values likepassword$123no longer produce a test file that fails to compile CodeBuilderrejectsnullconfig values withFormatExceptionnaming the offending key, instead of generating invalid Dart (static Null get ...)Map.mergedetects base/override type mismatches (e.g. primitive vs map) and raisesFormatExceptionwith context, instead of an opaqueTypeError
3.1.0 - 2026-04-13 #
Added #
- Support for
.ymland.jsonconfig file formats in addition to.yaml - Auto-detection of config file format with priority order:
.yaml>.yml>.json - Base and environment-specific files can use different formats (e.g., base in
.yaml, env override in.json) - Interactive prompt to enable/disable test file generation (
Generate test file?) - Configuration examples in
example/README.mdwith ready-to-use YAML and JSON templates
Changed #
- Reordered interactive CLI flow: mode and style first, then config input, then output options
- Improved interactive prompts with clearer descriptions (e.g.,
Config file name (without extension):,Output file name (without .dart):) ConfigReadernow probes for supported extensions instead of hardcoding.yaml- Error messages list all tried file paths when no config file is found
- Updated CLI description and README to reflect multi-format support
3.0.0 - 2026-04-12 #
Added #
- Strategy pattern architecture for obfuscation/encryption extensibility
- Multi-layer XOR obfuscation: per-value salt, byte shuffle, derived key XOR
- AES-256-GCM encryption mode via
--encrypt --key <base64_key>using fortis AesStrategyfor real encryption with runtime key initializationObfuscationStrategyabstract interface for obfuscation/encryption extensibility--encryptflag and--keyoption in CLIkeygencommand to generate random AES-256 keys- Automatic test file generation (
test/{file}_test.dart) with--[no-]testflag - Auto-detection of Flutter vs Dart projects and package name via
pubspec.yaml - Interactive CLI mode when running
genwithout arguments ConfigReaderfor independent YAML configuration loadingCodeBuilderandTestBuilderfor Dart source code generationbytes_utils.dartwith deterministic PRNG (seedFromSalt,generatePermutation)- Documentation in English, Portuguese, and Spanish (
doc/xor-obfuscation/,doc/aes-encryption/) - Comprehensive test suite rewritten from scratch
Changed #
- Refactored
Generatorinto a thin orchestrator delegating toConfigReader,CodeBuilder, andObfuscationStrategy - Replaced single global salt with per-value unique salts (32-64 bytes each)
- Salt is now fragmented into two parts in the generated file
- Renamed
encrypt_utils.darttobytes_utils.dart - Generated decode function now uses
String.fromCharCodesinstead ofUtf8Decoder - Generated file no longer requires
dart:convertimport
Removed #
- Old single-pass XOR obfuscation (
stringToHex,_encode) - Global
keyBytesSizegetter - Previous test suite (replaced entirely)
2.0.0 - 2025-09-02 #
Added #
- Support for primitive types: int, double, and bool in YAML configuration
Changed #
- Updated CLI commands for generating the encrypted file
- Default
case stylechanged to camelCase - Generated class is now declared as sealed
Fixed #
- Improved error message when YAML configuration is invalid
Removed #
- Removed all
// coverage:ignore-linedirectives
1.1.2 - 2025-05-19 #
Changed #
- Updated generator to insert
// coverage:ignore-linefor untestable lines - Renamed internal files for consistency and clarity
- Updated package dependencies to latest versions
1.1.0 - 2024-03-13 #
1.0.0 - 2024-03-13 #
- First release