PHPackages                             folded/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. folded/crypt

ActiveLibrary[Security](/categories/security)

folded/crypt
============

Easily encrypt and decrypt strings for your web app.

v0.1.1(5y ago)02MITPHPPHP &gt;=7.4.0

Since Sep 17Pushed 5y ago2 watchersCompare

[ Source](https://github.com/folded-php/crypt)[ Packagist](https://packagist.org/packages/folded/crypt)[ RSS](/packages/folded-crypt/feed)WikiDiscussions master Synced today

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

folded/crypt
============

[](#foldedcrypt)

Easily encrypt and decrypt strings for your web app.

[![Build Status](https://camo.githubusercontent.com/fd61c8f57ce1e7ef7dc1490fa71c676aa63823bc39d3d9f0f1a9d9d725b07267/68747470733a2f2f7472617669732d63692e636f6d2f666f6c6465642d7068702f63727970742e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/folded-php/crypt) [![Maintainability](https://camo.githubusercontent.com/806df7c5ba2db9fbe1527060d0a8355c218f361fffcd1758684a693be8e13a0b/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f38653539663765363130386164633635636136622f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/folded-php/crypt/maintainability) [![TODOs](https://camo.githubusercontent.com/e0119a23132a58faf7b28b54721cae6663bdb2d91b1c847f57fb8914b102bcc0/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f6170692e7469636b6769742e636f6d2f62616467653f7265706f3d6769746875622e636f6d2f666f6c6465642d7068702f6372797074)](https://www.tickgit.com/browse?repo=github.com/folded-php/crypt)

Summary
-------

[](#summary)

- [About](#about)
- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Examples](#examples)
- [Version support](#version-support)

About
-----

[](#about)

I created this library to be able to encrypt my data in a standalone way.

Folded is a constellation of packages to help you setting up a web app easily, using ready to plug in packages.

- [folded/action](https://github.com/folded-php/action): A way to organize your controllers for your web app.
- [folded/config](https://github.com/folded-php/config): Configuration utilities for your PHP web app.
- [folded/exception](https://github.com/folded-php/exception): Various kind of exception to throw for your web app.
- [folded/history](https://github.com/folded-php/history): Manipulate the browser history for your web app.
- [folded/http](https://github.com/folded-php/http): HTTP utilities for your web app.
- [folded/orm](https://github.com/folded-php/orm): An ORM for you web app.
- [folded/request](https://github.com/folded-php/request): Request utilities, including a request validator, for your PHP web app.
- [folded/routing](https://github.com/folded-php/routing): Routing functions for your PHP web app.
- [folded/session](https://github.com/folded-php/session): Session functions for your web app.
- [folded/view](https://github.com/folded-php/view): View utilities for your PHP web app.

Features
--------

[](#features)

- Can encrypt and decrypt strings
- Can generate a key (necessary to setup the library) from the command line

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

[](#requirements)

- PHP &gt;= 7.4.0
- Composer installed

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

[](#installation)

- [1. Install the package](#1-install-the-package)
- [2. Generate a key](#2-generate-a-key)
- [3. Add the setup code](#3-add-the-setup-code)

### 1. Install the package

[](#1-install-the-package)

In your root folder, run this command:

```
composer require folded/crypt
```

### 2. Generate a key

[](#2-generate-a-key)

One way to generate the key easily is through the command line. Run this command to get a new key:

```
vendor/bin/crypt generate key
```

You can get more information on the available option by running `vendor/bin/crypt generate --help`.

Another way is to call the function `Folded\getEncryptionKey()` from a script:

```
use function Folded\getEncryptionKey;

require __DIR__ . "/vendor/autoload.php";

echo getEncryptionKey();
```

You can add a parameter to control the type of cipher you want (currently supported: AES-128-CBC and AES-256-CBC).

### 3. Add the setup code

[](#3-add-the-setup-code)

Before calling the library, add this setup code as early as possible:

```
use function Folded\setEncryptionKey;

setEncryptionKey("xIYrZSsCV6hx9x/Q4bka1PejU+aSaMerJQFSYr3QnTE=");
```

Examples
--------

[](#examples)

- [1. Encrypt a string](#1-encrypt-a-string)
- [2. Decrypt a string](#2-decrypt-a-string)

### 1. Encrypt a string

[](#1-encrypt-a-string)

In this example, we will get the encrypted version of a string.

```
use function Folded\getEncryptedString;

$encryptedText = getEncryptedString("hello world");
```

### 2. Decrypt a string

[](#2-decrypt-a-string)

In this example, we will decrypt a previously encrypted text.

```
use function Folded\getDecryptedString;

$encryptedString = "...";
$decryptedString = getDecryptedString($encryptedString);
```

Note it will only decrypt encrypted string from the `getEncryptedString()` function.

Also note that if you encrypt a string with a key A, and you change the key A for a new key, the `getDecryptedString` will not be able to successfuly decrypt the text and get the original text so be careful to save your key in somewhere safe (generally in a .env file).

Version support
---------------

[](#version-support)

7.37.48.0v0.1.0❌✔️❓

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity46

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

Total

2

Last Release

2101d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15908747?v=4)[Anwar](/maintainers/khalyomede)[@khalyomede](https://github.com/khalyomede)

---

Top Contributors

[![khalyomede](https://avatars.githubusercontent.com/u/15908747?v=4)](https://github.com/khalyomede "khalyomede (14 commits)")

---

Tags

decryptionencryptionphp

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)

PHPackages © 2026

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