PHPackages                             phicorp/cipher - 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. phicorp/cipher

ActiveLibrary[Security](/categories/security)

phicorp/cipher
==============

Cipher: A tool for easier working with cryptography for PHP language

1.0.3(1y ago)2791MITPHP

Since Oct 5Pushed 1y ago1 watchersCompare

[ Source](https://github.com/phiCorp/cipher)[ Packagist](https://packagist.org/packages/phicorp/cipher)[ RSS](/packages/phicorp-cipher/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)DependenciesVersions (3)Used By (1)

Cipher
======

[](#cipher)

A tool for easier working with cryptography for PHP language

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

[](#installation)

Install Cipher with composer

```
composer require phicorp/cipher
```

Features
--------

[](#features)

- Easy to use
- Symmetric encryption and decryption with powerful AES algorithm
- Asymmetric encryption and decryption with RSA algorithm
- A variety of hash algorithms such as SHA and Bcrypt
- And more features

Usage/Examples
--------------

[](#usageexamples)

- Symmetric encryption and decryption:

```
$key = Cipher::AESKEY();
$iv = Cipher::AESIV();

$plaintext = 'Hello World!';

$ciphertext = encrypt($plaintext, $key, $iv);

$decryptedText = decrypt($ciphertext, $key, $iv);

echo "Original: $plaintext\n";
echo "Encrypted: $ciphertext\n";
echo "Decrypted: $decryptedText\n";
```

Or

```
$key = Cipher::AESKEY();
$iv = Cipher::AESIV();

$plaintext = 'Hello World!';

$ciphertext = Cipher::AES()->key($key)->iv($iv)->encrypt($plaintext);

$decryptedText = Cipher::AES()->key($key)->iv($iv)->decrypt($ciphertext);

echo "Original: $plaintext\n";
echo "Encrypted: $ciphertext\n";
echo "Decrypted: $decryptedText\n";
```

- GCM Mode symmetric encryption and decryption

```
$key = Cipher::AESKEY("AES-256-GCM");
$iv = Cipher::AESIV();
$tag = null;

$plaintext = 'Hello World!';

$ciphertext = Cipher::AES('GCM')->key($key)->iv($iv)->encrypt($plaintext, 0, $tag);

$decryptedText = Cipher::AES('GCM')->key($key)->iv($iv)->decrypt($ciphertext, 0, $tag);

echo "Original: $plaintext\n";
echo "Encrypted: $ciphertext\n";
echo "Decrypted: $decryptedText\n";
```

---

- Examples for asymmetric encryption and decryption

```
[$publicKey, $privateKey] = Cipher::RSAKEY();

$plaintext = 'hello world!';

$ciphertext = RSA($publicKey, $privateKey)->encryptPublic($plaintext);
$decryptedText = RSA($publicKey, $privateKey)->decryptPrivate($ciphertext);

echo "Original: $plaintext\n";
echo "Encrypted: $ciphertext\n";
echo "Decrypted: $decryptedText\n";

// You can also use it in this way

[$publicKey, $privateKey] = Cipher::RSAKEY();

$plaintext = 'hello world!';

$ciphertext = Cipher::RSA()->privateKey($privateKey)->encryptPrivate($plaintext);
$decryptedText = RSA()->publicKey($publicKey)->decryptPublic($ciphertext);

echo "Original: $plaintext\n";
echo "Encrypted: $ciphertext\n";
echo "Decrypted: $decryptedText\n";
```

---

- Example of using hash functions

```
sha512('Hello World!');
//output: 861844d6704e...
sha256('Hello World!');
//output: 7f83b1657ff1...
```

```
$hash = bcrypt('password', 15);

var_dump(bcrypt_verify('password', $hash));
// output: true
```

Authors
-------

[](#authors)

- [@thephibonacci](https://www.github.com/thephibonacci)

License
-------

[](#license)

[MIT](https://choosealicense.com/licenses/mit/)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

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

Total

2

Last Release

584d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/36b23edba8b24cc3b161efbed7939cfb4c83e991c49d1bae4273492dd721ecd2?d=identicon)[phiCorp](/maintainers/phiCorp)

---

Top Contributors

[![thephibonacci](https://avatars.githubusercontent.com/u/96210046?v=4)](https://github.com/thephibonacci "thephibonacci (7 commits)")

---

Tags

aescipherhashphiphprsacryptographyrsaaesMayacipherasymmetricsymmetricphi

### Embed Badge

![Health badge](/badges/phicorp-cipher/health.svg)

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

###  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)[miladrahimi/phpcrypt

Encryption, decryption, and hashing tools for PHP projects

3171.5k2](/packages/miladrahimi-phpcrypt)[poly-crypto/poly-crypto

High-level cryptographic functions that are interoperable between NodeJS and PHP 7.1+

127.8k1](/packages/poly-crypto-poly-crypto)[ionux/phactor

Phactor is a high-performance PHP implementation of the elliptic curve math functions required to generate &amp; verify private/public (asymmetric) EC keypairs and ECDSA signatures based on secp256k1 curve parameters. This library also includes a class to generate Service Identification Numbers (SINs) based on the published Identity Protocol v1 spec.

5275.0k30](/packages/ionux-phactor)

PHPackages © 2026

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