EnvironmentEncrypter class final

Laravel-compatible encrypted environment files (.env.encrypted), as written by php artisan env:encrypt and dartisan env:encrypt.

Two formats exist, both readable by either framework:

  • the default: the whole file, PHP-serialized (s:<bytes>:"...";) and encrypted as one Crypt payload;
  • --readable: one NAME=<payload> line per variable, so the names stay visible in diffs.

Constructors

EnvironmentEncrypter(String key, {EncryptionCipher cipher = .aes256cbc})

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

decrypt(String encrypted) → Future<String>
Decrypts either format back to dotenv text.
encrypt(String contents, {bool readable = false}) → Future<String>
Encrypts the contents of an environment file.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

appearsEncrypted(String value) → bool
Whether value is a single Crypt payload (Laravel's Encrypter::appearsEncrypted).
parseKey(String key) → List<int>
Laravel's key parsing: base64:<key> is decoded, anything else is used as raw bytes (32 characters for AES-256).

Constants

keyVariables → const List<String>
Environment variables that hold the key, in order of precedence.