2017 © Pedro Peláez
 

symfony-bundle eos-bundle

Symfony bundle for easy OpenSSL operations

image

b3da/eos-bundle

Symfony bundle for easy OpenSSL operations

  • Saturday, June 11, 2016
  • by b3da
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

b3da/EasyOpenSslBundle

Symfony Bundle for easy OpenSSL encryption, decryption and key pair generation.

Dependencies:

  • symfony/framework-standard-edition ">=2.8|~3.1"

Instalation:

  • create project with Symfony framework, (*1)

  • composer require b3da/eos-bundle "dev-master", (*2)

  • AppKernel.php:, (*3)

    new b3da\EasyOpenSslBundle\b3daEasyOpenSslBundle(),
      
  • parameters.yml(.dist):, (*4)

    # EasyOpenSSL encryption method
      eos_enc_method: aes-256-cbc
      # ...
      
  • (you can extend base Client and Message entities from b3da\EasyOpenSslBundle namespace), (*5)

  • update your schema, (*6)

Usage:

  • new service b3da_easy_open_ssl.eos is available for OpenSSL operations, (*7)

    $eos = $this->get('b3da_easy_open_ssl.eos');
      
  • create Client example (FooController), (*8)

    $client = new Client();
      $client = $eos->generateKeyPairForClient($client);
      if (!$client) {
         // err generating keypair
      }
      // persist Client with keys
      
  • encrypt data by Client's private key example (FooController), (*9)

    $message = $eos->encrypt($client, 'msg data .. foo bar baz');
      
  • decrypt data by Client's public key example (FooController), (*10)

    $decryptedData = $eos->decrypt($message);
      // $decryptedData === 'msg data .. foo bar baz';
      

simple API for basic tasks (optional)
  • import routes into routing.yml:, (*11)

    b3da_easy_open_ssl:
          resource: "@b3daEasyOpenSslBundle/Controller/"
          type:     annotation
          prefix:   /eos/
      
  • /eos/msg-api/client/create/ [POST], (*12)

    Response:
      
      {"status":"success","id":"3ead5521-2fbc-11e6-834a-f0def1ff5901"}
      
      or
      
      {"status":"error","details":"key pair generating failed"}
      
  • /eos/msg-api/client/export-public/{id}/ [GET], (*13)

    Response:
      
      {"status":"success","data":{"id":"3ead5521-2fbc-11e6-834a-f0def1ff5901","pubkey":"LS0tLS1CR .. S0tLQ=="}}
      
      or
      
      {"status":"error","details":"no client for id"}
      
  • /eos/msg-api/client/import-public/{id}/ [POST], (*14)

    Request:
      
      {"data":{"id":"3ead5521-2fbc-11e6-834a-f0def1ff5901","pubkey":"LS0tLS1CR .. S0tLQ=="}}
      
      Response:
      
      {"status":"success","id":"3ead5521-2fbc-11e6-834a-f0def1ff5901"}
      
      or
      
      {"status":"error","details":"no data to import"}
      
  • /eos/msg-api/msg/encrypt/{clientId}/{data}/ [GET], (*15)

    Response:
      
      {"status":"success","data":{"message":":774c6b663650636 .. 34346616f5901"}}
      
      or
      
      {"status":"error","details":"no client for id"}
      
  • /eos/msg-api/msg/decrypt/{data}/ [GET], (*16)

    Request:
      
      /eos/msg-api/msg/decrypt/{"message":":774c6b663650636 .. 34346616f5901"}/
      
      Response:
      
      {"status":"success","data":"foo bar"}
      
      or
      
      {"status":"error","details":"wrong format"}
      

The Versions

11/06 2016

dev-master

9999999-dev https://github.com/b3da-cz/EosBundle

Symfony bundle for easy OpenSSL operations

  Sources   Download

GPLv3

The Requires

 

symfony openssl