This repository provides a secure PHP class for encrypting and decrypting passwords (or any sensitive data) using AES-256-CBC encryption with a secret key.
password_hash()
and password_verify()
.
This library is meant for use cases where decryption is required (e.g., API keys, config values, temporary secrets).
- AES-256-CBC encryption (industry standard)
- Secret encryption key
- Secure IV (Initialization Vector) per encryption
- Base64 encoded output for safe storage
Just clone the repo or download the SecurePassword.php
file:
git clone https://github.com/DigitalEforce/php-secure-password.git
Then include it in your project:
require 'SecurePassword.php';
<?php
require 'SecurePassword.php';
$encryptionKey = "mySuperSecretKey123";
$secure = new SecurePassword($encryptionKey);
$password = "MyPassword@123";
$encrypted = $secure->encrypt($password);
echo "Encrypted: " . $encrypted . PHP_EOL;
$decrypted = $secure->decrypt($encrypted);
echo "Decrypted: " . $decrypted . PHP_EOL;
php-secure-password/
├── SecurePassword.php # Main class
├── example.php # Example usage (demo script)
└── README.md # Documentation
- Keep your encryption key private. If leaked, data can be decrypted.
- Do not use this for user login passwords → use hashing instead.
- Best suited for API keys, tokens, configs, temporary secrets.
MIT License – Free to use and modify.
DigitalEforce
- GitHub: DigitalEforce