PHPackages                             chippyash/crypt - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. chippyash/crypt

AbandonedLibrary[Security](/categories/security)

chippyash/crypt
===============

Simple cryptography

1.1.1(10y ago)051GPL 3.0PHPPHP &gt;=5.3CI failing

Since Oct 31Pushed 10y ago1 watchersCompare

[ Source](https://github.com/chippyash/Crypt)[ Packagist](https://packagist.org/packages/chippyash/crypt)[ Docs](http://zf4.biz/packages?utm_source=packagist&utm_medium=web&utm_campaign=blinks&utm_content=crypt)[ RSS](/packages/chippyash-crypt/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (5)Used By (0)

chippyash/Crypt
===============

[](#chippyashcrypt)

Quality Assurance
-----------------

[](#quality-assurance)

[![PHP 5.3](https://camo.githubusercontent.com/964ad5db1b8aa5aeeeac23d0964adc99f73b1b1548384aebfbcb5d2018983ca8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d352e332d626c75652e737667)](https://camo.githubusercontent.com/964ad5db1b8aa5aeeeac23d0964adc99f73b1b1548384aebfbcb5d2018983ca8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d352e332d626c75652e737667)[![PHP 5.4](https://camo.githubusercontent.com/27d753c231a6c9cfd43aa1ecc519bca8365f6a01ce6004452d4b3ca86e5b6756/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d352e342d626c75652e737667)](https://camo.githubusercontent.com/27d753c231a6c9cfd43aa1ecc519bca8365f6a01ce6004452d4b3ca86e5b6756/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d352e342d626c75652e737667)[![PHP 5.5](https://camo.githubusercontent.com/219e00452ba9998fcbfe00213b6eb56a8b86d19188783ed34d770d27b041df67/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d352e352d626c75652e737667)](https://camo.githubusercontent.com/219e00452ba9998fcbfe00213b6eb56a8b86d19188783ed34d770d27b041df67/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d352e352d626c75652e737667)[![PHP 5.6](https://camo.githubusercontent.com/88093c79af42bd3c07f4d6aa378289e1f5450411c56753b0323bd7d8b9b1f9ee/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d352e362d626c75652e737667)](https://camo.githubusercontent.com/88093c79af42bd3c07f4d6aa378289e1f5450411c56753b0323bd7d8b9b1f9ee/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d352e362d626c75652e737667)[![PHP 7](https://camo.githubusercontent.com/d23ce60b89c28c023d0ca69981ec9afbb17eb08a9cd1b609fd84c15d0732b7ce/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372d626c75652e737667)](https://camo.githubusercontent.com/d23ce60b89c28c023d0ca69981ec9afbb17eb08a9cd1b609fd84c15d0732b7ce/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372d626c75652e737667)[![Build Status](https://camo.githubusercontent.com/f3a53c99d19e83a5893897884a6834a38a1036e38b0709de24f2a17f90ac27b3/68747470733a2f2f7472617669732d63692e6f72672f6368697070796173682f43727970742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/chippyash/Crypt)[![Test Coverage](https://camo.githubusercontent.com/153f9959af66710121cc0206ec2ba9c781e576a02900dd7ecba6a99ec9427bd4/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6368697070796173682f43727970742f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/chippyash/Crypt/coverage)[![Code Climate](https://camo.githubusercontent.com/7d1c119937666bbec37c24af5e59f299942f79a36ace3539681693b8e922a770/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6368697070796173682f43727970742f6261646765732f6770612e737667)](https://codeclimate.com/github/chippyash/Crypt)

The above badges represent the current development branch. As a rule, I don't push to GitHub unless tests, coverage and usability are acceptable. This may not be true for short periods of time; on holiday, need code for some other downstream project etc. If you need stable code, use a tagged version. Read 'Further Documentation' and 'Installation'.

The Travis tests cover multiple versions of PHP. However, they do not allow usage of system commands, hence the getMac() method of Crypt.php doesn't work on the Travis servers. Check it out for yourself.

What?
-----

[](#what)

Provides a simple encryption capability

Why?
----

[](#why)

Encryption is not generally straightforward. This library tries to ease the pain. At the present time, a single verified encryption method is provided.

As the majority of web encryption requires that you are able to store the value in cookies, database tables etc, by default the encrypted value is encoded using Base 64. You can switch that off if required.

How
---

[](#how)

The encryption methods supported by this library all require an encryption key. You can generate this (on a \*nix based system at least,) by running `uuidgen`

You need to supply an encryption method to the Crypt class. At present one is provided for you, Rijndael256, but you can implement others by implementing the MethodInterface.

The supplied Rijndael256 method is capable of encrypting any PHP serializable object.

```
use Chippyash\Crypt\Crypt;
use Chippyash\Crypt\Crypt\Method\Rijndael256;
use chippyash\Type\String\StringType;
use chippyash\Type\BoolType;

$crypt = new Crypt(new StringType('my seed value'), new Rijndael256());

$encrypted = $crypt->encrypt($someValue);
$decrypted = $crypt->decrypt($encrypted);
```

By default the encrypted value is encoded using Base64. You can get the raw value thus:

```
$encrypted = $crypt->encrypt($someValue, new BoolType(false));
```

If you are not using Base64 encoding to encrypt, you need to switch it off in the decrypt as well:

```
$decrypted = $crypt->decrypt($encrypted, new BoolType(false));
```

By default, on \*nix based machines, the seed that you supply on construction is mixed with the mac address of the machine that the code is running on, if it can be found. This ensures that only that machine can encrypt and decrypt a given value. If you do not want this, say for instance that you are running on load balanced machines and storing in a central database, you can switch it off:

```
$crypt = new Crypt(new StringType('my seed value'), new Rijndael256());
$crypt->setUseMacAddress(new BoolType(false));
```

### Development only

[](#development-only)

**This library is no longer maintained and serves only as an example of encryption and as a holder for the work of others before me**

If you have a wish to pick this up and take it further, please contact me.

only on master branch at present

As an example of how you can wrap other libraries into this, I've supplied the Blowfish method, which requires the Zend Crypt library.

```
use Chippyash\Crypt\Crypt\Method\Blowfish;

$crypt = new Crypt(new StringType('my seed value'), new Blowfish());
```

If you want to do very serious cryptography the Zend Crypt library is a good starting point. If you just want sound and simple, use this library. You will need to use the now default `composer install` to bring in dev dependencies to use the Zend stuff. If you like it then add `"zendframework/zend-crypt": "~2.5.0"`to your project composer 'requires' statement;

Further documentation
---------------------

[](#further-documentation)

[Test Contract](https://github.com/chippyash/Crypt/blob/master/docs/Test-Contract.md) in the docs directory. For Symfony users, you'll also find an example DIC definition in the docs directory

Check out [ZF4 Packages](http://zf4.biz/packages?utm_source=github&utm_medium=web&utm_campaign=blinks&utm_content=crypt) for more packages

### UML

[](#uml)

[![class diagram](https://github.com/chippyash/Crypt/raw/master/docs/crypt-classes.png)](https://github.com/chippyash/Crypt/blob/master/docs/crypt-classes.png)

Changing the library
--------------------

[](#changing-the-library)

1. fork it
2. write the test
3. amend it
4. do a pull request

Found a bug you can't figure out?

1. fork it
2. write the test
3. do a pull request

NB. Make sure you rebase to HEAD before your pull request

Or - raise an issue ticket.

Where?
------

[](#where)

The library is hosted at [Github](https://github.com/chippyash/Crypt). It is available at [Packagist.org](https://packagist.org/packages/chippyash/crypt)

### Installation

[](#installation)

Install [Composer](https://getcomposer.org/)

#### For production

[](#for-production)

```
    "chippyash/crypt": "~1.0.0"
```

Or to use the latest, possibly unstable version:

```
    "chippyash/crypt": "dev-master"
```

To use the Zend cryptography lib under my lib add the `"zendframework/zend-crypt": "~2.5.0"`line to your composer require section.

#### For development

[](#for-development)

Clone this repo, and then run Composer in local repo root to pull in dependencies

```
    git clone git@github.com:chippyash/Crypt.git Crypt
    cd Crypt
    composer install
```

To run the tests:

```
    cd Crypt
    vendor/bin/phpunit -c test/phpunit.xml test/
```

License
-------

[](#license)

This software library is released under the [GNU GPL V3 or later license](http://www.gnu.org/copyleft/gpl.html)

This software library is Copyright (c) 2015, Ashley Kitson, UK

This software library contains code items that are derived from other works:

None of the contained code items breaks the overriding license, or vice versa, as far as I can tell. So as long as you stick to GPL V3+ then you are safe. If at all unsure, please seek appropriate advice.

If the original copyright owners of the derived code items object to this inclusion, please contact the author.

A commercial license is available for this software library, please contact the author. It is normally free to deserving causes, but gets you around the limitation of the GPL license, which does not allow unrestricted inclusion of this code in commercial works.

Thanks
------

[](#thanks)

I didn't do this by myself. I'm deeply indebted to those that trod the path before me.

The Rijndael256 cryptography method is based on code created by Andrew Johnson. I can find no current location or link for Andrew, so if you know him (he created Cryptastic,) please do let me know.

History
-------

[](#history)

V1.0.0 Initial Release

V1.1.0 Update dependencies

V1.1.1 Add link to packages

Abandoned.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~47 days

Total

4

Last Release

3755d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/198575568597b367c8b285de16d278018c8cf292c6c75c535270135c1eea0561?d=identicon)[chippyash](/maintainers/chippyash)

---

Top Contributors

[![chippyash](https://avatars.githubusercontent.com/u/983560?v=4)](https://github.com/chippyash "chippyash (17 commits)")

---

Tags

encryptiondecryption

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/chippyash-crypt/health.svg)

```
[![Health](https://phpackages.com/badges/chippyash-crypt/health.svg)](https://phpackages.com/packages/chippyash-crypt)
```

###  Alternatives

[nzo/url-encryptor-bundle

The NzoUrlEncryptorBundle is a Symfony Bundle used to Encrypt and Decrypt data and variables in the Web application or passed through URL

971.1M2](/packages/nzo-url-encryptor-bundle)[camcima/dukpt-php

DUKPT implementation in PHP

26154.0k](/packages/camcima-dukpt-php)[legierski/aes

OpenSSL-compatible AES library

1142.3k1](/packages/legierski-aes)[mukto90/ncrypt

A simple PHP class to encrypt a string and decrypt an encrypted string

1614.1k](/packages/mukto90-ncrypt)[al-saloul/encryption

Simple number encryption and decryption package

181.5k](/packages/al-saloul-encryption)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
