Skip to content

DigitalEforce/php-secure-password

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

🔐 PHP Secure Password Encryption & Decryption

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.

⚠️ Note: For user authentication (logins), always use password_hash() and password_verify().
This library is meant for use cases where decryption is required (e.g., API keys, config values, temporary secrets).


🚀 Features

  • AES-256-CBC encryption (industry standard)
  • Secret encryption key
  • Secure IV (Initialization Vector) per encryption
  • Base64 encoded output for safe storage

📦 Installation

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';

📝 Example Usage

<?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;

📂 Repo Structure

php-secure-password/
 ├── SecurePassword.php   # Main class
 ├── example.php          # Example usage (demo script)
 └── README.md            # Documentation

🛡️ Security Notes

  • 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.

📜 License

MIT License – Free to use and modify.


👨‍💻 Author

DigitalEforce

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages