119b3d2db4e6dcfa6976393b63243e4333bb2a4b
SafePaste
A minimal, encrypted pastebin built with PHP, MySQL, and Redis.
Features
- AES-256-CBC encryption — all pastes are encrypted at rest using a master key
- Optional password protection — bcrypt-hashed passwords per paste
- TTL expiry via Redis — short-lived pastes live only in Redis; permanent pastes use MySQL
- Clean dark UI — responsive, accessible, no external dependencies
Project Structure
safe-paste/
├── app/
│ ├── config/config.php # Loads .env settings
│ ├── core/
│ │ ├── db.php # PDO connection
│ │ ├── redis.php # Redis singleton
│ │ └── security.php # Encrypt/decrypt helpers
│ ├── controllers/
│ │ ├── SaveController.php # POST handler: create paste
│ │ └── ViewController.php # GET/POST handler: view paste
│ └── models/Paste.php # Save/get paste (Redis + MySQL)
└── public/
├── index.php # Home page + save action
├── view.php # View paste page
├── error.php # Error page
├── .htaccess # URL routing
└── assets/
├── css/style.css
└── js/app.js
Setup
- Copy
.env.exampleto.envand fill in your values - Create the MySQL database and table:
CREATE DATABASE paste CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE paste;
CREATE TABLE pastes (
id CHAR(32) PRIMARY KEY,
encrypted_text TEXT NOT NULL,
iv VARCHAR(64) NOT NULL,
expire_time INT DEFAULT NULL,
password_hash VARCHAR(255) DEFAULT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
- Point your web server document root to
public/ - Ensure
mod_rewriteis enabled (Apache) or configure your nginx equivalent
.env
MASTER_KEY=your-random-secret-key
DB_HOST=localhost
DB_NAME=paste
DB_USER=root
DB_PASS=secret
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
APP_URL=https://yourdomain.com
Description
Languages
PHP
61.8%
CSS
27%
JavaScript
11.2%