An open API service indexing awesome lists of open source software.

https://github.com/shgysk8zer0/phpcrypt

Provides a variety of cryptographic traits and classes to PHP
https://github.com/shgysk8zer0/phpcrypt

aes aes256 cryptography jscrypt php php-7 phpcrypt rsa spl-autoload traits

Last synced: 2 months ago
JSON representation

Provides a variety of cryptographic traits and classes to PHP

Awesome Lists containing this project

README

          

# PHPCrypt

[![Join the chat at https://gitter.im/shgysk8zer0/phpcrypt](https://badges.gitter.im/shgysk8zer0/phpcrypt.svg)](https://gitter.im/shgysk8zer0/phpcrypt?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/shgysk8zer0/phpcrypt.svg?branch=master)](https://travis-ci.org/shgysk8zer0/phpcrypt)
> Provides easy to use classes and traits for cryptographic functions using `openssl_*`. Intended
> to be compatible with [JSCrypt](https://github.com/shgysk8zer0/JSCrypt) &
> [SubtleCrypto / JWK](https://developer.mozilla.org/en-US/docs/Web/API/CryptoKey)

## Requires:
- **PHP >= 7**
- [openssl](https://secure.php.net/manual/en/book.openssl.php)

## Installation:
- Best if imported as a Git submodule using [`git submodule add git://github.com/shgysk8zer0/phpcrypt.git`](https://git-scm.com/book/en/v2/Git-Tools-Submodules)
- Use [`spl_autoload`](https://secure.php.net/manual/en/function.spl-autoload-register.php) for autoloading

## Provided classes:
- [`PublicKey`](https://github.com/shgysk8zer0/phpcrypt/blob/master/publickey.php)
- [`PrivateKey`](https://github.com/shgysk8zer0/phpcrypt/blob/master/privatekey.php)
- [`KeyPair`](https://github.com/shgysk8zer0/phpcrypt/blob/master/keypair.php)
- [`FormSign`](https://github.com/shgysk8zer0/phpcrypt/blob/master/formsign.php)

## Provided traits:
- [`Traits\KeyPair`](https://github.com/shgysk8zer0/phpcrypt/blob/master/traits/keypair.php)
- [`Traits\AES`](https://github.com/shgysk8zer0/phpcrypt/blob/master/traits/aes.php)
- [`Traits\Password`](https://github.com/shgysk8zer0/phpcrypt/blob/master/traits/password.php)

## Provided interfaces:
- [`Interfaces\Key`](https://github.com/shgysk8zer0/phpcrypt/blob/master/interfaces/key.php)

### Example code:
```php
encrypt(MESSAGE);
$decrypted = $keys->decrypt($encrypted);
$sig = $keys->sign($encrypted);
$valid = $keys->verify($encrypted, $sig);
$matches = MESSAGE === $decrypted;
```