PHPackages                             jdz/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. jdz/crypt

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jdz/crypt
=========

Simple Crypt/Decrypt utility

3.0.1(3mo ago)010↓100%MITPHPPHP &gt;=8.1

Since Dec 3Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/joffreydemetz/crypt)[ Packagist](https://packagist.org/packages/jdz/crypt)[ Docs](https://jdz.joffreydemetz.com/crypt/)[ RSS](/packages/jdz-crypt/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (6)Dependencies (1)Versions (8)Used By (0)

Crypt
=====

[](#crypt)

Simple crypt/decrypt utility

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

[](#installation)

To install the package, you can use Composer:

```
composer require jdz/crypt
```

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

[](#requirements)

- PHP 8.1 or higher
- Composer for dependency management

Usage
-----

[](#usage)

### Basic Example

[](#basic-example)

```
use JDZ\Crypt\Crypt;
use JDZ\Crypt\SimpleCipher;
use JDZ\Crypt\Key;

// Create a key
$key = new Key('my-secret-passphrase');

// Create cipher and crypt instances
$cipher = new SimpleCipher();
$crypt = new Crypt($cipher, $key);

// Encrypt
$originalText = 'Secret message';
$encrypted = $crypt->encrypt($originalText);

// Decrypt
$decrypted = $crypt->decrypt($encrypted);

echo $decrypted; // Output: Secret message
```

### Available Ciphers

[](#available-ciphers)

The library provides three cipher implementations:

1. **SimpleCipher** - Uses the passphrase directly as the encryption key
2. **Md5Cipher** - Uses MD5 hash of the passphrase (32 characters)
3. **Sha1Cipher** - Uses SHA1 hash of the passphrase (40 characters)

All ciphers use XOR-based encryption and extend from `SimpleCipher`.

### Key Generation

[](#key-generation)

You can generate keys automatically using the generator classes:

```
use JDZ\Crypt\SimpleGenerator;
use JDZ\Crypt\Md5Generator;
use JDZ\Crypt\Sha1Generator;

// Simple generator
$generator = new SimpleGenerator();
$key = $generator->generateKey();

// MD5 generator
$md5Generator = new Md5Generator();
$md5Key = $md5Generator->generateKey();

// SHA1 generator
$sha1Generator = new Sha1Generator();
$sha1Key = $sha1Generator->generateKey();
```

### Manual Key Creation

[](#manual-key-creation)

```
use JDZ\Crypt\Key;

// Single key (public and private are the same)
$key = new Key('my-passphrase');

// Separate public and private keys
$key = new Key('public-key', 'private-key');
```

Examples
--------

[](#examples)

The `examples/` directory contains:

- **simple.php** - Basic usage with SimpleCipher and key generation
- **md5.php** - MD5-based encryption with auto-generated and manual keys
- **sha1.php** - SHA1-based encryption with auto-generated and manual keys
- **comparison.php** - Comparison of all cipher types
- **benchmark.php** - Performance comparison and timing benchmarks

Run an example:

```
php examples/simple.php
php examples/md5.php
php examples/sha1.php
```

Compare and benchmark:

```
php examples/comparison.php
php examples/benchmark.php
```

Testing
-------

[](#testing)

### Run Tests

[](#run-tests)

Run all tests:

```
composer test
# or
vendor/bin/phpunit
```

Run tests with coverage report (HTML):

```
composer test-coverage
# Coverage report will be generated in the coverage/ directory
```

### Test Structure

[](#test-structure)

Tests are located in the `tests/` directory and follow the PSR-4 autoloading standard under the `JDZ\Crypt\Tests` namespace.

- `KeyTest.php` - Tests for the Key class
- `SimpleCipherTest.php` - Tests for the SimpleCipher implementation
- `CryptTest.php` - Tests for the main Crypt class

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance82

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity77

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

Recently: every ~735 days

Total

6

Last Release

94d ago

Major Versions

1.2.0 → 2.0.02018-05-13

2.0.1 → 3.0.02025-12-03

PHP version history (3 changes)1.1.0PHP &gt;=5.6

2.0.0PHP ^7.1.3

3.0.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/5e83e3701566e43438525ed14578487e732b849d152b5071aa1613a0dad96913?d=identicon)[jdz](/maintainers/jdz)

---

Top Contributors

[![joffreydemetz](https://avatars.githubusercontent.com/u/15113527?v=4)](https://github.com/joffreydemetz "joffreydemetz (16 commits)")

---

Tags

cryptutilitiesJDZ

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[vaimo/composer-patches

Applies a patch from a local or remote file to any package that is part of a given composer project. Patches can be defined both on project and on package level. Optional support for patch versioning, sequencing, custom patch applier configuration and patch command for testing/troubleshooting added patches.

2994.3M16](/packages/vaimo-composer-patches)[lodash-php/lodash-php

A port of Lodash to PHP

527719.0k5](/packages/lodash-php-lodash-php)[kartik-v/yii2-helpers

A collection of useful helper functions for Yii Framework 2.0

883.0M29](/packages/kartik-v-yii2-helpers)[longman/ip-tools

PHP IP Tools for manipulation with IPv4 and IPv6

147245.6k6](/packages/longman-ip-tools)[mathiasverraes/classfunctions

Functions to manipulate class names

34472.6k10](/packages/mathiasverraes-classfunctions)[andreas-glaser/php-helpers

A comprehensive collection of PHP utility functions for array manipulation, string operations, date handling, HTML generation, form building, validation, and more. Modern PHP 8.2+ library with full type safety.

1386.5k2](/packages/andreas-glaser-php-helpers)

PHPackages © 2026

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