Automatic Encrypt and Decrypt your database data. Tested and used on Laravel 8

Overview

Laravel Encrypt Database

Automatic Encrypt and Decrypt your database data. Tested and used on Laravel 8. I'm yet building the tests.

Important

  • Note the key used to encrypt your data is your app_key, so keep it in a secure place.
  • If you lose it, you will lose all your database data.

  • The $casts attribute is not available for encrypted fields yet.

  • It is highly recommended to alter your encrypted column types to TEXT or LONGTEXT

Features

  • Minimal configuration
  • Encrypt and Decrypt database fields easily
  • Include searching encrypted data using the following: whereEncrypted and orWhereEncrypted
  • Include unique_encrypted, exists_encrypted rules
  • Uses openssl for encrypting and decrypting fields

Requirements

Laravel >= 8.0
PHP >= 7.4

Installing

Install the package

composer require wellingtoncarneirobarbosa/laravel-encrypt-database

Add the service provider on your providers list config/app.php:168

WellingtonCarneiroBarbosa\EncryptDatabase\Providers\EncryptDatabaseProvider::class,

Publish the config file

php artisan vendor:publish --tag=laravel-database-encryption

Usage

Just use the trait on yours encryptables models and list the encryptable fields.

use WellingtonCarneiroBarbosa\EncryptDatabase\Traits\EncryptableModel;

class User extends Authenticable
{
    Use HasFactory,
        EncryptableModel;
        
    /**
    * The attributes that should be encrypted.
    *
    * @var array
    */
    protected $encryptable = [
        'name',
        'email',
        'birth_date',
    ];
}

Note if you have a mutator on your model like "setNameAttribute" you should implement manually the encrypt method
public function setNameAttribute(string $value)
{
  $value = ucwords($value);
  
  $this->attributes['name'] = $this->encrypt('name', $value);
}

You also should implement manually decrypt method if you have an acessor method
public function getNameAttribute()
{
  $decrypted = $this->decrypt('name', $this->attributes['name']);

  $value = strtolower($decrypted);
  
  return $value;
}

If you are validating your form data with unique or exists you should replace it to unique_encrypted and exists_encrypted respectively

You might also like...
A simple php (lumen) app for sharing sensitive text (basically like onetimesecret), but with full end-to-end AES-256-GCM encryption so even the server has no access to the data, and developed with very simple deployment in mind.
A simple php (lumen) app for sharing sensitive text (basically like onetimesecret), but with full end-to-end AES-256-GCM encryption so even the server has no access to the data, and developed with very simple deployment in mind.

A simple php (lumen) app for sharing sensitive text (basically like onetimesecret), but with full end-to-end AES-256-GCM encryption so even the server has no access to the data, and developed with very simple deployment in mind.

Pretty Good Privacy (PGP) is an encryption program that provides cryptographic privacy and authentication for data communication.

Pretty Good Privacy (PGP) is an encryption program that provides cryptographic privacy and authentication for data communication. PGP is used for signing, encrypting, and decrypting texts, e-mails, files, directories, and whole disk partitions and to increase the security of e-mail communications. Phil Zimmermann developed PGP in 1991.

Run locally to export crypto tx data from crypto exchanges using their api connections, and process into a normalised format.

CryptoCredible The missing crypto-exchange data exporter tldr: run locally to export your crypto tx data from popular exchanges via api connections. E

SЁCU is a public API to store self-destructing data payloads with url shortener and handle anonymous chat-rooms.
SЁCU is a public API to store self-destructing data payloads with url shortener and handle anonymous chat-rooms.

SЁCU Introduction SЁCU is a public API to store self-destructing data payloads. This repository includes only backend part using Laravel framework. Fr

HTML/PHP/CSS website that tracks two API data
HTML/PHP/CSS website that tracks two API data

Detailed instructions on how to build and run Step 1: download XAMPP for a live web server XAMPP download 1 XAMP download 2 Step 2: Download all files

Easily anonymize sensitive data through eloquent queries
Easily anonymize sensitive data through eloquent queries

Laravel Encryptable This package allows you to anonymize sensitive data (like the name, surname and email address of a user) similarly to Laravel's En

🔒 Password Exposed Helper Function - Check if a password has been exposed in a data breach.
🔒 Password Exposed Helper Function - Check if a password has been exposed in a data breach.

🔒 Password Exposed Helper Function This PHP package provides a password_exposed helper function, that uses the haveibeenpwned.com API to check if a p

Fides provides your servers with a trusted CA certificate, and signs your OpenSSH certificates with the same key

Fides is an SSH certificate signing server. It enables zero-trust infrastructure for your engineers by dynamically, and transparently, issuing short-lived certificates with clearly defined permissions.

PHPIDS (PHP-Intrusion Detection System) is a simple to use, well structured, fast and state-of-the-art security layer for your PHP based web application

PHPIDS PHPIDS (PHP-Intrusion Detection System) is a simple to use, well structured, fast and state-of-the-art security layer for your PHP based web ap

Owner
Wellington Barbosa
Fullstack Laravel developer since 2019.
Wellington Barbosa
encrypt HMAC SHA1 with simple PHP

HMAC Tugas UTS SKJ 1 MALAM Nama : MOCHAMMAD SIDIQ C.A. NIM : 1814321019 Create Hmac Buka terminal powershell pada visual studioCode (dahal hal ini

Shidiq Mochsi 2 Jan 10, 2022
Automatic SQL injection and database takeover tool

sqlmap sqlmap is an open source penetration testing tool that automates the process of detecting and exploiting SQL injection flaws and taking over of

sqlmapproject 25.7k Jan 5, 2023
Ransomware with automatic Coinbase Commerce integration created in C# (Console) and PHP

AWare — C# Ransomware Ransomware with automatic Coinbase Commerce integration created in C# (Console) and PHP PD: AWare is just a proof of concept, wi

in the space 26 Sep 16, 2022
Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.

Themis provides strong, usable cryptography for busy people General purpose cryptographic library for storage and messaging for iOS (Swift, Obj-C), An

Cossack Labs 1.6k Jan 6, 2023
A minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted/decrypted in the browser using 256 bits AES.

Current version: 1.3.5 PrivateBin is a minimalist, open source online pastebin where the server has zero knowledge of pasted data. Data is encrypted a

null 4.6k Jan 7, 2023
Fast, general Elliptic Curve Cryptography library. Supports curves used in Bitcoin, Ethereum and other cryptocurrencies (secp256k1, ed25519, ..)

Fast Elliptic Curve Cryptography in PHP Information This library is a PHP port of elliptic, a great JavaScript ECC library. Supported curve types: Sho

Simplito 178 Dec 28, 2022
Damn Vulnerable Web Services is an insecure web application with multiple vulnerable web service components that can be used to learn real world web service vulnerabilities.

Damn Vulnerable Web Services is an insecure web application with multiple vulnerable web service components that can be used to learn real world web service vulnerabilities.

Sam Sanoop 416 Dec 17, 2022
Obfuscate your data by generating reversible, non-sequential, URL-safe identifiers.

Laravel Hashid Laravel Hashid provides a unified API across various drivers such as Base62, Base64, Hashids and Optimus, with support for multiple con

Elf Sundae 390 Nov 16, 2022
A database of PHP security advisories

PHP Security Advisories Database The PHP Security Advisories Database references known security vulnerabilities in various PHP projects and libraries.

null 1.9k Dec 18, 2022