fixer112/encrypter

Simple AES-256-CBC encrypter decrypter

Installs: 6

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/fixer112/encrypter

v1.2.0 2025-06-03 01:37 UTC

This package is auto-updated.

Last update: 2025-10-03 02:21:37 UTC


README

Simple AES-256-CBC encryption/decryption PHP library using fixed key and IV loaded from environment variables.

Installation

Install via Composer:

composer require fixer112/encrypter

Environment Setup

Create a .env file in your project root with these variables:

ENCRYPTER_KEY=your-secret-key-here
ENCRYPTER_IV=your-iv-here

Usage

<?php

require 'vendor/autoload.php';

use Fixer112\Encrypter\Encrypter;



try {
    // Load .env (if not using Laravel, you need to load it manually)
    $dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
    $dotenv->load();

    $encrypter = new Encrypter();

    //or initiate key and iv

    //$key = $iv = "password";
    //$encrypter = new Encrypter($key,$iv);

    $plaintext = "Hello, world!";
    $encrypted = $encrypter->encrypt($plaintext);
    echo "Encrypted: " . $encrypted . PHP_EOL;

    $decrypted = $encrypter->decrypt($encrypted);
    echo "Decrypted: " . $decrypted . PHP_EOL;

} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}

Notes

  • This package depends on your .env file to provide ENCRYPTER_KEY and ENCRYPTER_IV.

  • Make sure to keep your key and IV secret and do not commit them to public repositories.