PHPackages                             bigb06/phpcypherfile - 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. bigb06/phpcypherfile

ActiveLibrary[Security](/categories/security)

bigb06/phpcypherfile
====================

A PHP library for encrypting and decrypting files using the AES-256-CBC algorithm.

v1.0.2(1y ago)1111MITPHPPHP &gt;=8.2

Since Dec 10Pushed 1y ago1 watchersCompare

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

READMEChangelog (1)DependenciesVersions (4)Used By (0)

PHPCypherFile
=============

[](#phpcypherfile)

PHPCypherFile provides a robust solution for encrypting large files securely without significant memory overhead. It combines the power of RSA for public/private key encryption and AES-256-CBC for symmetric encryption, ensuring both performance and security.

Features
--------

[](#features)

1. Large File Support:

    Files are encrypted in chunks, minimizing memory usage during the encryption/decryption process. This ensures scalability for handling large files.
2. Hybrid Encryption Scheme:

    - random symmetric key is generated for AES-256-CBC encryption of the file content.
    - The symmetric key and IV (Initialization Vector) are encrypted with a public RSA key.
3. Output Structure: The encrypted file includes the following components:

    - RSA-encrypted symmetric key.
    - RSA-encrypted IV.
    - AES-encrypted file data.
4. Security Standards:

    - AES-256-CBC ensures high-speed, secure encryption for the data.
    - RSA encryption secures the transmission of the symmetric key, leveraging a public/private key pair.
5. Minimal Memory Footprint:

    By processing files in small chunks, the class avoids loading the entire file into memory.

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

[](#installation)

To install this library, you can use Composer. Run the following command:

```
composer require bigb06/phpcypherfile
```

Example
-------

[](#example)

Basic code to use PHPCypherFile (see example.php for full example and keys generation):

```
use PHPCypherFile\PHPCypherFile;

// Encrypt the file
PHPCypherFile::encryptFile($inputFile, $encryptedFile,$publicKey);

// Decrypt the file
PHPCypherFile::decryptFile($encryptedFile, $decryptedFile,$privateKey);
```

### Keys Generation

[](#keys-generation)

```
$config = [
    "private_key_bits" => 4096,
    "private_key_type" => OPENSSL_KEYTYPE_RSA,
];
$res = openssl_pkey_new($config);
openssl_pkey_export($res, $privateKeyString);
$details = openssl_pkey_get_details($res);
$publicKeyString = $details["key"];
$publicKey = openssl_pkey_get_public($publicKeyString);
$privateKey = openssl_pkey_get_private($privateKeyString);
```

You can also refer to example.php for detailed steps on how to generate the required RSA public/private keys for encryption and decryption.

🙇 Author
--------

[](#-author)

- [Nicolas Chevallier](https://www.nicolas-chevallier.fr/) [Linkedin Bio](https://www.linkedin.com/in/nicolas-chevallier-525677/)

🙇 Acknowledgements
------------------

[](#-acknowledgements)

- [Antoine Lame](https://medium.com/@antoine.lame/how-to-encrypt-files-with-php-f4adead297de) for the inital idea

License
-------

[](#license)

This project is open source and available under the [MIT License](LICENSE).

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance43

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

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

Total

3

Last Release

459d ago

### Community

Maintainers

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

---

Tags

cypherencryptionphp

### Embed Badge

![Health badge](/badges/bigb06-phpcypherfile/health.svg)

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

###  Alternatives

[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k16.7M113](/packages/mews-purifier)[robrichards/xmlseclibs

A PHP library for XML Security

41478.1M118](/packages/robrichards-xmlseclibs)[bjeavons/zxcvbn-php

Realistic password strength estimation PHP library based on Zxcvbn JS

87117.5M63](/packages/bjeavons-zxcvbn-php)[illuminate/encryption

The Illuminate Encryption package.

9229.7M280](/packages/illuminate-encryption)[paragonie/hidden-string

Encapsulate strings in an object to hide them from stack traces

7410.6M39](/packages/paragonie-hidden-string)

PHPackages © 2026

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