Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

Package allows you to create Doctrine entities with fields that will be protected by encryption algorithms such as AES.

License

Notifications You must be signed in to change notification settings

nepda/doctrine-encrypt

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DoctrineEncrypt

Build Status

Package encrypts and decrypts Doctrine fields through life cycle events. This version of the Doctrine Encrypt package distinguishes itself with the following features:

  • Superior Annotation parsing & caching using Doctrine's built in libraries for superior performance
  • Totally transparent field encryption: the value will only be encrypted in the database, never in the value
  • Unit testing

Tests

Tests currently run with PHP 7.1, 7.2

Installation

Add nepda/doctrine-encrypt to your Composer manifest.

{
    "require": {
        "nepda/doctrine-encrypt": "~7.0"
    }
}

Configuration

Using ZF2

Check out the doctrine-encrypt-module at https://github.com/nepda/doctrine-encrypt-module

Manually

Add the event subscriber to your entity manager's event manager. Assuming $em is your configured entity manager:

<?php

//You should pick your own hexadecimal secret
$secret = pack("H*", "dda8e5b978e05346f08b312a8c2eac03670bb5661097f8bc13212c31be66384c");

$subscriber = new DoctrineEncryptSubscriber(
    new \Doctrine\Common\Annotations\AnnotationReader,
    new \DoctrineEncrypt\Encryptors\AES256Encryptor($secret)
);

$eventManager = $em->getEventManager();
$eventManager->addEventSubscriber($encrypt_subscriber);

Usage

<?php

namespace Your\CoolNamespace;

use Doctrine\ORM\Mapping as ORM;

use DoctrineEncrypt\Configuration\Encrypted;

/**
 * @ORM\Entity
 */
class Entity
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     * @ORM\Column(type="integer")
     * @var int
     */
    protected $id;

    /**
     * @ORM\Column(type="text")
     * @Encrypted
     * @var string
     */
    protected $secret_data;
}

License

This bundle is under the MIT license. See the complete license in the bundle

Versions

I'm using Semantic Versioning like described here.

About

Package allows you to create Doctrine entities with fields that will be protected by encryption algorithms such as AES.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%