PHPackages                             martinusso/opencrypt - 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. martinusso/opencrypt

ActiveLibrary[Security](/categories/security)

martinusso/opencrypt
====================

Two-way encryption (encrypt and decrypt) data using PHP with OpenSSL

3.1.0(8y ago)820.3k41MITPHPPHP ^5.6 || ^7.0

Since Oct 23Pushed 8y ago1 watchersCompare

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

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

opencrypt
=========

[](#opencrypt)

[![Build Status](https://camo.githubusercontent.com/7cc3af2601ecaf722807236f26bb69f73eca9dc19b32c162ad7cdca2ca68ec6c/68747470733a2f2f7472617669732d63692e6f72672f6d617274696e7573736f2f6f70656e63727970742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/martinusso/opencrypt)[![Build Status](https://camo.githubusercontent.com/1277303d45e6447cbf57ccb8212149defab6ca954fc85a3a7547aea44a7dac05/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d617274696e7573736f2f6f70656e63727970742f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/martinusso/opencrypt/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/b886abb3a53f9034b9ed56d414cc3e56a60ad04bd0ee62219f0ac68d71d30ad7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d617274696e7573736f2f6f70656e63727970742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/martinusso/opencrypt/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/cad6a59242d42d00dab8a37f9296d7add16cad5e1d3c642d2b52ea93c5660323/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d617274696e7573736f2f6f70656e63727970742f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/martinusso/opencrypt/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/c10ad7f0c43efd6e00737ba32c432385e07bf8a9d2c4fe3d9c9a215e1d8fb05e/68747470733a2f2f706f7365722e707567782e6f72672f6d617274696e7573736f2f6f70656e63727970742f762f737461626c65)](https://packagist.org/packages/martinusso/opencrypt)[![Latest Unstable Version](https://camo.githubusercontent.com/00ab8c43a500fbbde5ec29597722de5a1bc6199795f5c4139847c4db408f2a28/68747470733a2f2f706f7365722e707567782e6f72672f6d617274696e7573736f2f6f70656e63727970742f762f756e737461626c65)](https://packagist.org/packages/martinusso/opencrypt)[![License](https://camo.githubusercontent.com/33878c93f3b15332cd3076b1ec0d1b896716e5ef9aea899fba71a4e3de6d2837/68747470733a2f2f706f7365722e707567782e6f72672f6d617274696e7573736f2f6f70656e63727970742f6c6963656e7365)](https://packagist.org/packages/martinusso/opencrypt)[![composer.lock](https://camo.githubusercontent.com/263c3c1c5723cc87470c18c39985f59269a26910696a7f05027244effc5d5e0c/68747470733a2f2f706f7365722e707567782e6f72672f6d617274696e7573736f2f6f70656e63727970742f636f6d706f7365726c6f636b)](https://packagist.org/packages/martinusso/opencrypt)

Two-way encryption (encrypt and decrypt) data using PHP with OpenSSL

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

[](#installation)

`composer require martinusso/opencrypt`

Tips
----

[](#tips)

- *$secretKey* should have been previously generated in a cryptographically safe way, like [openssl\_random\_pseudo\_bytes](http://php.net/manual/en/function.openssl-random-pseudo-bytes.php). OpenCrypt has a static method `OpenCrypt::generateKey()` for this.

Usage
-----

[](#usage)

```
$password = "OpenCrypt";

// Should have been previously generated in a cryptographically safe way
$secretKey = 'SECRET_KEY';

// You can pass the IV as argument or it is generated automatically
$openCrypt = new OpenCrypt($secretKey [, string $iv ]);

// get the IV
$iv = $openCrypt->iv();

// encrypt
$encryptedPassword = $openCrypt->encrypt($password);
// $encryptedPassword = 'GWw3bqL7FqjmRs0yyIR/8A=='

// decrypt
$decryptedPassword = $openCrypt->decrypt($encryptedPassword);
// $decryptedPassword = 'OpenCrypt'

```

### generate IV

[](#generate-iv)

OpenCrypt offers a static method to generate a safe IV:

```
$iv = OpenCrypt::generateIV();

```

### generate key

[](#generate-key)

it is also possible to generate a safe secret key:

```
$secretKey = OpenCrypt::generateKey();

```

License
-------

[](#license)

This software is open source, licensed under the The MIT License (MIT). See [LICENSE](https://github.com/martinusso/opencrypt/blob/master/LICENSE) for details.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity61

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

Total

4

Last Release

3126d ago

Major Versions

1.0.0 → 2.0.02017-10-24

2.0.0 → 3.0.02017-10-24

### Community

Maintainers

![](https://www.gravatar.com/avatar/055f0fd274c2261d698750c403323e930c4406adfee9f1dce50a13ef05bf2ba0?d=identicon)[martinusso](/maintainers/martinusso)

---

Top Contributors

[![martinusso](https://avatars.githubusercontent.com/u/158559?v=4)](https://github.com/martinusso "martinusso (24 commits)")

---

Tags

decryptencryptopensslphpphpencryptdecryptopenssl

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/martinusso-opencrypt/health.svg)

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

###  Alternatives

[hemiframe/php-aes

PHP class for encrypt and decrypt data with AES algorithm

1030.3k](/packages/hemiframe-php-aes)[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)[mpyw/easycrypt

A class that provides simple interface for decryptable encryption.

234.7k](/packages/mpyw-easycrypt)

PHPackages © 2026

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