envvault


Nameenvvault JSON
Version 0.1.7 PyPI version JSON
download
home_pageNone
SummaryA tool to manage encrypted environment variables.
upload_time2025-01-24 02:36:41
maintainerNone
docs_urlNone
authorjin
requires_python<4.0,>3.9.1
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # EnvVault

EnvVault is a Python package for encrypting and managing `.env` files, similar to Rails Credentials. It allows you to securely store sensitive information (such as API keys, database passwords, etc.) and decrypt and use this information at runtime.

## Features

- **Encrypt `.env` files**: Encrypt plaintext `.env` files into `.env.enc` files.
- **Decrypt `.env.enc` files**: Decrypt `.env.enc` files at runtime and load environment variables.
- **Multi-environment support**: Create separate encrypted files for different environments (e.g., `development`, `production`).
- **Dynamic field support**: Automatically define fields in `Settings` based on the contents of `.env.enc`.
- **Type inference**: Automatically infer field types (e.g., `str`, `int`, `bool`) from environment variable values.
- **CLI tool**: Provides a command-line interface for managing encrypted files.
- **Integration with `pydantic_settings`**: Supports managing decrypted environment variables using `pydantic_settings`.

---

### **Dynamic Field Support**

EnvVault dynamically creates `Settings` fields based on the contents of the `.env.enc` file. For example, if your `.env.enc` file contains:

```yaml
API_KEY=your_api_key_here
DATABASE_URL=your_database_url_here
DEBUG=true
PORT=8080
```

EnvVault will automatically create the following fields in the `Settings` class:

- `API_KEY` (string)
- `DATABASE_URL` (string)
- `DEBUG` (boolean)
- `PORT` (integer)

---

### **Type Inference**

EnvVault supports automatic type inference for environment variables. For example:

- `DEBUG=true` → `DEBUG` is inferred as a boolean.
- `PORT=8080` → `PORT` is inferred as an integer.
- `API_KEY=your_api_key_here` → `API_KEY` is inferred as a string.

---

## Installation

Install using Poetry:

```bash
poetry add envvault

# Or install using pip:
pip install envvault
```

## Usage

### 1. Initialize

Initialize the `master key` and an empty `.env.enc` file:

```bash
envvault init --env development
```

This will generate the following files:
- `master.key`: The master key used for encryption and decryption.
- `.env.development.enc`: An empty encrypted file.

---

### 2. Edit Encrypted File

Edit the `.env.enc` file using your default editor:

```bash
envvault edit --env development
```

The editor will open a temporary file. After editing, the content will be re-encrypted and saved to `.env.development.enc`.

---

### 3. View Decrypted Environment Variables

Decrypt and view the contents of the `.env.enc` file:

```bash
envvault view --env development
```

Enter the following content in the editor:

```yaml
API_KEY=your_api_key_here
DATABASE_URL=your_database_url_here
DEBUG=true
PORT=8080
```

---
### 4. Regenerate master.key

Regenerate the master key for the `development` environment:

```bash
envvault rekey --env development
```

---

### 5. Use in Code

Load decrypted environment variables in your code:

```python
from envvault.settings import Settings

# Load configuration for the development environment
settings = Settings.from_credentials(env_name="development")
print("API Key:", settings.API_KEY)
print("Database URL:", settings.DATABASE_URL)
```

### or

```python
from envvault.settings import get_settings

# Load configuration for the current environment
envvault = get_settings()
print("API Key:", envvault.API_KEY)
print("Database URL:", envvault.DATABASE_URL)
```

---

## Configuration

### Default Editor

You can set the default editor using the `EDITOR` environment variable. For example:

```bash
export EDITOR=code  # Use VS Code
export EDITOR=nano  # Use Nano
export EDITOR=vim   # Use Vim
```

---

### Master Key Retrieval

EnvVault retrieves the master key value first from the `MASTER_KEY` environment variable, and if not found, from the `master.key` file. This allows for flexibility in managing the master key.

---

### Multi-Environment Support

EnvVault supports creating separate encrypted files for different environments. For example:

- `.env.development.enc`: Development environment.
- `.env.enc`: Production environment.

Specify the environment name using the `--env` parameter in CLI commands.

---

## Contributing

Issues and Pull Requests are welcome!

---

## License

MIT


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "envvault",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>3.9.1",
    "maintainer_email": null,
    "keywords": null,
    "author": "jin",
    "author_email": "jin.xiaoming@ekohe.com",
    "download_url": "https://files.pythonhosted.org/packages/47/58/9dc9be663b95f22f7a05490d93ede3b04d9ad8f6670fc2d7733a77a2d856/envvault-0.1.7.tar.gz",
    "platform": null,
    "description": "# EnvVault\n\nEnvVault is a Python package for encrypting and managing `.env` files, similar to Rails Credentials. It allows you to securely store sensitive information (such as API keys, database passwords, etc.) and decrypt and use this information at runtime.\n\n## Features\n\n- **Encrypt `.env` files**: Encrypt plaintext `.env` files into `.env.enc` files.\n- **Decrypt `.env.enc` files**: Decrypt `.env.enc` files at runtime and load environment variables.\n- **Multi-environment support**: Create separate encrypted files for different environments (e.g., `development`, `production`).\n- **Dynamic field support**: Automatically define fields in `Settings` based on the contents of `.env.enc`.\n- **Type inference**: Automatically infer field types (e.g., `str`, `int`, `bool`) from environment variable values.\n- **CLI tool**: Provides a command-line interface for managing encrypted files.\n- **Integration with `pydantic_settings`**: Supports managing decrypted environment variables using `pydantic_settings`.\n\n---\n\n### **Dynamic Field Support**\n\nEnvVault dynamically creates `Settings` fields based on the contents of the `.env.enc` file. For example, if your `.env.enc` file contains:\n\n```yaml\nAPI_KEY=your_api_key_here\nDATABASE_URL=your_database_url_here\nDEBUG=true\nPORT=8080\n```\n\nEnvVault will automatically create the following fields in the `Settings` class:\n\n- `API_KEY` (string)\n- `DATABASE_URL` (string)\n- `DEBUG` (boolean)\n- `PORT` (integer)\n\n---\n\n### **Type Inference**\n\nEnvVault supports automatic type inference for environment variables. For example:\n\n- `DEBUG=true` \u2192 `DEBUG` is inferred as a boolean.\n- `PORT=8080` \u2192 `PORT` is inferred as an integer.\n- `API_KEY=your_api_key_here` \u2192 `API_KEY` is inferred as a string.\n\n---\n\n## Installation\n\nInstall using Poetry:\n\n```bash\npoetry add envvault\n\n# Or install using pip:\npip install envvault\n```\n\n## Usage\n\n### 1. Initialize\n\nInitialize the `master key` and an empty `.env.enc` file:\n\n```bash\nenvvault init --env development\n```\n\nThis will generate the following files:\n- `master.key`: The master key used for encryption and decryption.\n- `.env.development.enc`: An empty encrypted file.\n\n---\n\n### 2. Edit Encrypted File\n\nEdit the `.env.enc` file using your default editor:\n\n```bash\nenvvault edit --env development\n```\n\nThe editor will open a temporary file. After editing, the content will be re-encrypted and saved to `.env.development.enc`.\n\n---\n\n### 3. View Decrypted Environment Variables\n\nDecrypt and view the contents of the `.env.enc` file:\n\n```bash\nenvvault view --env development\n```\n\nEnter the following content in the editor:\n\n```yaml\nAPI_KEY=your_api_key_here\nDATABASE_URL=your_database_url_here\nDEBUG=true\nPORT=8080\n```\n\n---\n### 4. Regenerate master.key\n\nRegenerate the master key for the `development` environment:\n\n```bash\nenvvault rekey --env development\n```\n\n---\n\n### 5. Use in Code\n\nLoad decrypted environment variables in your code:\n\n```python\nfrom envvault.settings import Settings\n\n# Load configuration for the development environment\nsettings = Settings.from_credentials(env_name=\"development\")\nprint(\"API Key:\", settings.API_KEY)\nprint(\"Database URL:\", settings.DATABASE_URL)\n```\n\n### or\n\n```python\nfrom envvault.settings import get_settings\n\n# Load configuration for the current environment\nenvvault = get_settings()\nprint(\"API Key:\", envvault.API_KEY)\nprint(\"Database URL:\", envvault.DATABASE_URL)\n```\n\n---\n\n## Configuration\n\n### Default Editor\n\nYou can set the default editor using the `EDITOR` environment variable. For example:\n\n```bash\nexport EDITOR=code  # Use VS Code\nexport EDITOR=nano  # Use Nano\nexport EDITOR=vim   # Use Vim\n```\n\n---\n\n### Master Key Retrieval\n\nEnvVault retrieves the master key value first from the `MASTER_KEY` environment variable, and if not found, from the `master.key` file. This allows for flexibility in managing the master key.\n\n---\n\n### Multi-Environment Support\n\nEnvVault supports creating separate encrypted files for different environments. For example:\n\n- `.env.development.enc`: Development environment.\n- `.env.enc`: Production environment.\n\nSpecify the environment name using the `--env` parameter in CLI commands.\n\n---\n\n## Contributing\n\nIssues and Pull Requests are welcome!\n\n---\n\n## License\n\nMIT\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A tool to manage encrypted environment variables.",
    "version": "0.1.7",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "109b08ad1e410c10856c3793ad93088482cc0865496ef0375cc16283b82039e6",
                "md5": "734ab7c6ec3a991109dfbb4195f8744d",
                "sha256": "1032927fece4f4161e77509e9f4d8427f2aaadb8b1eac8513e97d9435d643393"
            },
            "downloads": -1,
            "filename": "envvault-0.1.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "734ab7c6ec3a991109dfbb4195f8744d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>3.9.1",
            "size": 6636,
            "upload_time": "2025-01-24T02:36:39",
            "upload_time_iso_8601": "2025-01-24T02:36:39.607021Z",
            "url": "https://files.pythonhosted.org/packages/10/9b/08ad1e410c10856c3793ad93088482cc0865496ef0375cc16283b82039e6/envvault-0.1.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "47589dc9be663b95f22f7a05490d93ede3b04d9ad8f6670fc2d7733a77a2d856",
                "md5": "451ac0a022ad5de7e3e27e681d1f115b",
                "sha256": "57eb3632025ff62c19246e9931718a332cdb88f28557d9eafa5c0bf99947c7c6"
            },
            "downloads": -1,
            "filename": "envvault-0.1.7.tar.gz",
            "has_sig": false,
            "md5_digest": "451ac0a022ad5de7e3e27e681d1f115b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>3.9.1",
            "size": 5699,
            "upload_time": "2025-01-24T02:36:41",
            "upload_time_iso_8601": "2025-01-24T02:36:41.406277Z",
            "url": "https://files.pythonhosted.org/packages/47/58/9dc9be663b95f22f7a05490d93ede3b04d9ad8f6670fc2d7733a77a2d856/envvault-0.1.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-24 02:36:41",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "envvault"
}
        
jin
Elapsed time: 0.65422s