2017 © Pedro Peláez
 

library openssl

OpenSsl wrapper library

image

psx/openssl

OpenSsl wrapper library

  • Thursday, June 1, 2017
  • by k42b3
  • Repository
  • 1 Watchers
  • 1 Stars
  • 9,453 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 3 Versions
  • 11 % Grown

The README.md

OpenSsl

About

Wrapper to the openssl_* functions. Each method throws directly an exception in case an error occurred., (*1)

Usage

Encrypt/Decrypt

<?php

$data   = 'Secret text';
$key    = 'foobar';
$method = 'aes-128-cbc';
$iv     = substr(md5('foo'), 4, 16);

$encrypt = OpenSsl::encrypt($data, $method, $key, 0, $iv);

$this->assertEquals('U1dIdXBaY25uOTRaZ3dhZ1l6QzQwZz09', base64_encode($encrypt));

$decrypt = OpenSsl::decrypt($encrypt, $method, $key, 0, $iv);

$this->assertEquals($data, $decrypt);

Sign/Verify

<?php

$pkey = PKey::newPrivate('private.pem', 'foobar');
$data = 'Some content';

OpenSsl::sign($data, $signature, $pkey);

$result = OpenSsl::verify($data, $signature, $pkey);

$this->assertEquals('S9zEMrH5RTYkC/iUiHCbDUP9MkrsivkN23QffRuTD7bMiWn5neP4QX+36zO3ynELWUSyQ6woqNO37y6KQK1t6Nk3Etkau9IplBFga8ZDBcfMIMdJmWKXWmWzycgAorxjglFkdUSer8vc1tvf4v05msufJKwg/E853ZVZuB//vb/idxBH/GPeguGw8jm3DVEn3tpmypJMd/pzBwAzWB7USG8TsSDyXhxPt8pO3ZGCJn3IPbXo6eMMx+7ad/6yyxxHwu60Ab2F5hOIiC0UR15OLH5X7plJFWPTobi95GrVfHHHNRli1zquTt5T8cu+v3Q6W1ZOeSPqF7o7pn2nUjantQ==', base64_encode($signature));
$this->assertEquals(1, $result);

$data = 'Some content corrupted';

$result = OpenSsl::verify($data, $signature, $pkey);

$this->assertEquals(0, $result);

Digest

<?php

$this->assertContains('sha256', OpenSsl::getMdMethods());

$data = OpenSsl::digest('foobar', 'sha256');

$this->assertEquals('c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2', $data);

The Versions

01/06 2017

dev-master

9999999-dev http://phpsx.org

OpenSsl wrapper library

  Sources   Download

Apache-2.0

The Requires

  • php >=5.6

 

The Development Requires

openssl

02/04 2016

v0.1.0

0.1.0.0 http://phpsx.org

OpenSsl wrapper library

  Sources   Download

Apache-2.0

The Requires

  • php >=5.5

 

The Development Requires

openssl

02/04 2016

v1.0.0

1.0.0.0 http://phpsx.org

OpenSsl wrapper library

  Sources   Download

Apache-2.0

The Requires

  • php >=5.5

 

The Development Requires

openssl