PHPackages                             codecollab/encryption - 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. codecollab/encryption

ActiveLibrary[Security](/categories/security)

codecollab/encryption
=====================

Encryption package of the CodeCollab project

2.0.0(9y ago)25401See the LICENSE filePHPPHP ^7

Since Dec 7Pushed 8y ago1 watchersCompare

[ Source](https://github.com/CodeCollab/Encryption)[ Packagist](https://packagist.org/packages/codecollab/encryption)[ Docs](https://github.com/CodeCollab/Encryption)[ RSS](/packages/codecollab-encryption/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (2)Versions (4)Used By (1)

Encryption
==========

[](#encryption)

Encryption package of the CodeCollab project

[![Build Status](https://camo.githubusercontent.com/24c628966ee1d778b5532bc012baea4c1cea4ca7f120ad47398029c15f7e9049/68747470733a2f2f7472617669732d63692e6f72672f436f6465436f6c6c61622f456e6372797074696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/CodeCollab/Encryption) [![MIT License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](mit) [![Latest Stable Version](https://camo.githubusercontent.com/1a98a5343e0bb9650830586ec30ac5c9aac6d961445306743ad4d61a88bc30d4/68747470733a2f2f706f7365722e707567782e6f72672f636f6465636f6c6c61622f656e6372797074696f6e2f762f737461626c65)](https://packagist.org/packages/codecollab/encryption) [![Total Downloads](https://camo.githubusercontent.com/cd0151dde3a227757f797eaf14f0b30a0ecdfdd3ca510c18363e37fd03afdbf5/68747470733a2f2f706f7365722e707567782e6f72672f636f6465636f6c6c61622f656e6372797074696f6e2f646f776e6c6f616473)](https://packagist.org/packages/codecollab/encryption) [![Latest Unstable Version](https://camo.githubusercontent.com/ec25b0d50dc7bb61c42e0f971252e69418e856ae36591312f3c9b53a56ad31a3/68747470733a2f2f706f7365722e707567782e6f72672f636f6465636f6c6c61622f656e6372797074696f6e2f762f756e737461626c65)](https://packagist.org/packages/codecollab/encryption)

Requirements
------------

[](#requirements)

PHP7+

Installation
------------

[](#installation)

Include the library in your project using composer:

```
{
    "require-dev": {
        "codecollab/encryption": "^2"
    }
}

```

Usage
-----

[](#usage)

This library provides common interfaces and exceptions for handling crypto in your applications.

### Generating key

[](#generating-key)

Before being able to encrypt/decrypt data a key needs to be generated / added. To generate a new key use:

```
$key = (new \CodeCollab\Encryption\Defusev2\Key())->generate();

```

*Note: keys should always be stored in a secure location and should never be made public.*

*Note: all key share the common `CodeCollab\Encryption\Key` interface.*

### Encrypting

[](#encrypting)

```
$encryptedData = (new \CodeCollab\Encryption\Defusev2\Encryptor($key))->encrypt('the data to encrypt');

```

*Note: all encryptors share the common `CodeCollab\Encryption\Encryptor` interface.*

### Decrypting

[](#decrypting)

```
$decryptedData = (new \CodeCollab\Encryption\Defusev2\Decryptor($key))->decrypt($encryptedData);

```

*Note: all decryptors share the common `CodeCollab\Encryption\Decryptor` interface.*

To decrypt old data encrypted with v1\* of this library use the deprecated:

```
$decryptedData = (new \CodeCollab\Encryption\Defuse\Decryptor($key))->decrypt($encryptedData);

```

Using your current key. For newly encrypted data create a new and separate key.

### Exceptions

[](#exceptions)

This library may emit two different exceptions:

- `\CodeCollab\Encryption\CryptoException`
- `\CodeCollab\Encryption\FraudException`

It is important to properly handle these exceptions in your applications.

#### `CryptoException`

[](#cryptoexception)

This exception gets thrown when a key could not be generated or when a message could not be en- / decrypted because of system errors.

#### `FraudException`

[](#fraudexception)

This exception gets thrown when there has been suspected tampering with messages. This exception should be handled like the message has been tampered with and precautions should be taken.

Upgrading
---------

[](#upgrading)

When upgrading from from v1\* to v2\* of this library there are breaking changes.

It's not possible anymore to generate a new key or encrypt data using the obsolete `CodeCollab\Encryption\Defuse\Key` and `CodeCollab\Encryption\Defuse\Encrypt` classes.

The `CodeCollab\Encryption\Defuse` package has been superseded by the ``CodeCollab\\Encryption\\Defusev2` package.

Decrypting of data is still possible using the deprecated `CodeCollab\Encryption\Defuse\Decrypt::decrypt()` method and will be for the foreseeable future.

It is however *strongly* advised to re-encrypt old data using the new `CodeCollab\Encryption\Defusev2` package.

The workflow for this will be:

- Generate a new key using the new `CodeCollab\Encryption\Defusev2\Key::generate()` method (**But don't overwrite the current key yet!**)
- Decrypt the data using the current key and the `CodeCollab\Encryption\Defuse\Decrypt::decrypt()` method
- Encrypt the data using the new `CodeCollab\Encryption\Defusev2\Encrypt::encrypt()` method with the newly generate key
- Newly encrypted data can now be decrypted using the new `CodeCollab\Encryption\Defusev2\Decrypt::decrypt()` method

Contributing
------------

[](#contributing)

[How to contribute](https://github.com/CodeCollab/Encryption/blob/master/CONTRIBUTING.md)

License
-------

[](#license)

[MIT](http://spdx.org/licenses/MIT)

Security issues
---------------

[](#security-issues)

If you found a security issue please contact directly by mail instead of using the issue tracker at

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity65

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 ~109 days

Total

3

Last Release

3597d ago

Major Versions

1.0.2 → 2.0.02016-07-12

PHP version history (3 changes)1.0.1PHP &gt;=7.0-dev

1.0.2PHP 7.0.\*

2.0.0PHP ^7

### Community

Maintainers

![](https://www.gravatar.com/avatar/ce6ea4ee501375bd1be563f6deed94e889d57d6134e98486208e5bcd14026ec2?d=identicon)[PeeHaa](/maintainers/PeeHaa)

---

Top Contributors

[![PeeHaa](https://avatars.githubusercontent.com/u/1330296?v=4)](https://github.com/PeeHaa "PeeHaa (62 commits)")

---

Tags

securityencryptionRijndaelcodecollab

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/codecollab-encryption/health.svg)

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

###  Alternatives

[phpseclib/phpseclib

PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.

5.6k434.8M1.3k](/packages/phpseclib-phpseclib)[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[ass/xmlsecurity

The XmlSecurity library is written in PHP for working with XML Encryption and Signatures

955.6M30](/packages/ass-xmlsecurity)[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

961.0M2](/packages/nzo-url-encryptor-bundle)[tilleuls/url-signer-bundle

Create and validate signed URLs with a limited lifetime in Symfony

81340.1k](/packages/tilleuls-url-signer-bundle)[ercsctt/laravel-file-encryption

Secure file encryption and decryption for Laravel applications

642.6k](/packages/ercsctt-laravel-file-encryption)

PHPackages © 2026

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