snipershady/securecipher

A free, reliable and easy-to-use cipher to encrypt and decrypt strings

Installs: 235

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/snipershady/securecipher

v1.0.8 2025-12-09 13:57 UTC

This package is auto-updated.

Last update: 2025-12-09 15:11:26 UTC


README

Latest Version PHP Version License Stars Issues

A free, reliable, and easy-to-use PHP library for encrypting and decrypting strings with advanced cipher methods.

📋 Table of Contents

🎯 Overview

SecureCipher is a robust PHP library designed to help you enhance your application's security by providing easy-to-use encryption and decryption capabilities. Whether you need to protect sensitive user data or secure system-level information, SecureCipher offers a straightforward API with flexible cipher method options.

✨ Features

  • Multiple Cipher Methods: Support for various AES encryption algorithms
  • User-Level Encryption: Customize encryption with user-specific keys
  • System-Wide Base Key: Set a system base key for additional security layer
  • Simple API: Intuitive methods for encryption and decryption
  • Type-Safe: Utilizes PHP enumerations for cipher method selection
  • Well-Tested: Comprehensive test coverage

📦 Installation

Install SecureCipher via Composer:

composer require snipershady/securecipher

🚀 Usage

Basic Example

<?php

use SecureCipher\Service\SecureCipher;

// Initialize with a system-wide base key
$baseKey = "your-secure-base-key";
$userKey = "user-specific-key";

$sc = new SecureCipher($baseKey);

// Original data to encrypt
$data = "ForzaNapoli";

// Encrypt the data with the user's personal key
$encryptedData = $sc->encrypt($data, $userKey);

// Store $encryptedData in your database or file system

// Later, retrieve and decrypt the data
$decryptedData = $sc->decrypt($encryptedData, $userKey);

// Verify the decryption
assert($data === $decryptedData); // true

Custom Cipher Methods

The default cipher method is AES_256_CBC, but you can select a different method using the CipherMethod enumeration:

<?php

use SecureCipher\Service\SecureCipher;
use SecureCipher\Enum\CipherMethod;

$baseKey = "your-secure-base-key";
$userKey = "user-specific-key";

$sc = new SecureCipher($baseKey);
$data = "Sensitive Information";

// Encrypt with AES-128-CBC
$encryptedData = $sc->encrypt($data, $userKey, CipherMethod::AES_128_CBC);

// Decrypt with the same cipher method
$decryptedData = $sc->decrypt($encryptedData, $userKey, CipherMethod::AES_128_CBC);

// ⚠️ Important: The cipher method must be the same for both encryption and decryption

🔐 Available Cipher Methods

SecureCipher supports multiple cipher methods through the CipherMethod enumeration:

  • AES_256_CBC (default) - Advanced Encryption Standard with 256-bit key
  • AES_128_CBC - Advanced Encryption Standard with 128-bit key
  • AES_192_CBC - Advanced Encryption Standard with 192-bit key
  • Additional methods available in the CipherMethod enum

Check the CipherMethod enum class for the complete list of supported encryption algorithms.

🛡️ Security Considerations

  • Key Management: Store your base keys and user keys securely. Never commit them to version control.
  • Key Strength: Use strong, randomly generated keys for both base and user keys.
  • Cipher Method Consistency: Always use the same cipher method for encryption and decryption.
  • HTTPS: Transmit encrypted data over secure connections (HTTPS) when applicable.
  • Regular Updates: Keep the library updated to benefit from security patches and improvements.

📋 Requirements

  • PHP 8.3 or higher
  • OpenSSL extension enabled

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

This project is licensed under the GPL-3.0 License - see the LICENSE file for details.

Made with ❤️ by snipershady