2017 © Pedro Peláez
 

library datasafe

Services to secure data by providing Crypt and Uncrypt API

image

rbaaboud/datasafe

Services to secure data by providing Crypt and Uncrypt API

  • Wednesday, May 16, 2018
  • by rbaaboud
  • Repository
  • 1 Watchers
  • 2 Stars
  • 23 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 283 % Grown

The README.md

rbaaboud/datasafe

Services to secure data by providing Crypt and Uncrypt API., (*1)

Install

Via Composer, (*2)

``` bash, (*3)

$ composer require rbaaboud/datasafe, (*4)


## Setup __settings / app parameters__ ```php <?php return [ 'datasafe' => [ 'crypt' => [ // method, see openssl_get_cipher_methods() 'method' => 'AES-256-CFB', // key, see openssl_encrypt() 'key' => 'vr6EkKQ8S8vuxnchzKJbmqPUbkm9mX5L', // options, see openssl_encrypt() 'options' => 0, // iv, see openssl_encrypt() and openssl_cipher_iv_length() 'iv' => 'cvXKhMvNk2LEYpG2' ] ] ];

dependencies / services, (*5)

Register service in Container., (*6)

Factory ensures that valid settings are present and runs validator., (*7)


<?php /** * @param \Psr\Container\ContainerInterface $container * @return \Rbaaboud\DataSafe\Crypt */ $container['datasafe'] = function (\Psr\Container\ContainerInterface $container) { $factory = new \Rbaaboud\DataSafe\Crypt\Factory(); // settings $settingsService = $container->get('settings'); // formatter // or a custom formatter that implements \Rbaaboud\DataSafe\Formatter\FormatterInterface $formatter = new \Rbaaboud\DataSafe\Formatter(); return $factory($settingsService['datasafe']['crypt'], $formatter); };

Usage


<?php // get datasafe service /** @var \Rbaaboud\DataSafe\Crypt $datasafeService */ $datasafeService = $this->container->get('datasafe'); // crypt // returns crypted string $datasafeService->crypt('test'); // cryptArray // returns array with all values crypted $datasafeService->cryptArray([ 'foo', 'bar' ]); // returns array with only 'index2' value crypted $datasafeService->cryptArray([ 'index1' => 'foo', 'index2' => 'bar' ], [ 'index2' ]); // uncrypt // returns uncrypted string $datasafeService->uncrypt('d91wtw=='); // uncryptArray // returns array with all values uncrypted $datasafeService->uncryptArray([ 'Zdds', 'd91wtw==' ]); // returns array with only 'index2' value uncrypted $datasafeService->uncryptArray([ 'index1' => 'Zdds', 'index2' => 'd91wtw==' ], [ 'index2' ]);

Testing


$ composer test

The Versions

16/05 2018

dev-master

9999999-dev

Services to secure data by providing Crypt and Uncrypt API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ramzi Baaboud

14/05 2018

1.0.2

1.0.2.0

Services to secure data by providing Crypt and Uncrypt API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ramzi Baaboud

14/05 2018

dev-develop

dev-develop

Services to secure data by providing Crypt and Uncrypt API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ramzi Baaboud

02/05 2018

1.0.1

1.0.1.0

Services to secure data by providing Crypt and Uncrypt API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ramzi Baaboud

01/05 2018

1.0.0

1.0.0.0

Services to secure data by providing Crypt and Uncrypt API

  Sources   Download

MIT

The Requires

 

by Ramzi Baaboud