PHPackages                             koltsov/justencrypt - 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. koltsov/justencrypt

ActiveLibrary[Security](/categories/security)

koltsov/justencrypt
===================

0.2.1(7y ago)014MITPHP

Since Jan 23Pushed 7y agoCompare

[ Source](https://github.com/KoltsovAnton/justencrypt-php)[ Packagist](https://packagist.org/packages/koltsov/justencrypt)[ RSS](/packages/koltsov-justencrypt/feed)WikiDiscussions master Synced 5d ago

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

### JustEncrypt PHP library

[](#justencrypt-php-library)

===========================

[![Build Status](https://camo.githubusercontent.com/987821b4e5095e7c0d4c31ae24dcf3237b66461ef7ca12b9fd8be014aed48438/68747470733a2f2f7472617669732d63692e6f72672f627463636f6d2f6a757374656e63727970742d7068702e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/btccom/justencrypt-php)[![Code Coverage](https://camo.githubusercontent.com/d09e98bd61a4acf89fc346afb23c5b616dfa40c04806e96b883ae5e730079a70/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f627463636f6d2f6a757374656e63727970742d7068702f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/btccom/justencrypt-php/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/60509a50443d2e78f879e16aca4b4ffdd31e4aa2e6956965a32691cec8152f38/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f627463636f6d2f6a757374656e63727970742d7068702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/btccom/justencrypt-php/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/7b18952dc1d3ee33e6bffa7110cde54623a341078f41f0ad0aa695e060464aba/68747470733a2f2f706f7365722e707567782e6f72672f627463636f6d2f6a757374656e63727970742d7068702f762f737461626c652e706e67)](https://packagist.org/packages/btccom/justencrypt)

#### PHP Support

[](#php-support)

This library supports PHP versions 5.6 through 7.1. Using PHP 7.1 is *highly*recommended, because the OpenSSL extension now supports the algorithm we use. Otherwise, you fall back on a much slower implementation in native PHP.

Usage
-----

[](#usage)

#### Key Derivation

[](#key-derivation)

The following example shows simple key derivation from a password/salt/iterations [Simple derivation example](examples/simple_key_derivation.php)

`KeyDerivation::generateSalt()` will return a salt using the current default. `Encryption::encrypt` will generate the salt/iterations above using library defaults

#### Encryption

[](#encryption)

An encrypted blob is the concatenation of `saltLen (uint8) || salt || iv || ct || tag`The serialized parameters allow us to decrypt on any machine knowing only the password.

[Simple encryption example](examples/simple_encryption.php)[Advanced example with subkeys &amp; root key recovery](examples/example.php)

Encryption::encrypt returns an [EncryptedBlob](src/EncryptedBlob.php), which encapsulates key derivation data and ciphertext details. It also exposes useful methods for the ciphertext:

- `$blob->getBinary()` - returns raw binary for encrypted blob, for base64, etc.
- `$blob->getMnemonic()` - returns the Encryption Mnemonic (see below)
- `$blob->getBuffer()` - returns a Buffer, useful for converting to hex, etc

#### Encryption Mnemonic

[](#encryption-mnemonic)

To make the result of encrypt human readable (so it is easier to write down) it's possible to encode it as an mnemonic. We're using the Bitcoin BIP39 way of encoding entropy to mnemonic, but ignoring the (weak) password protection BIP39 originally had. We also ensure the data is padded correctly.

`$encrypted->getMnemonic()` calls the `EncryptedMnemonic` class to produce [Encryption Mnemonic example](examples/simple_encryption_mnemonic.php)

#### Choosing iterations

[](#choosing-iterations)

The default iterations is `justencrypt.KeyDerivation.defaultIterations` and is set to **35000**, this is a number that should remain secure enough for a while when using a password.
If you don't pass in the `iterations` argument it will default to this.

If you're encrypting with a CSPRNG generated random byte string as the password then you can use the same code, except in that case setting the iterations to 1 is secure as there's no need to stretch the password.
You can use `justencrypt.KeyDerivation.subkeyIterations` in that case to make it clear what your intentions are.

This type of usage is demonstrated in [this example](examples/example.php)

Development / Contributing
--------------------------

[](#development--contributing)

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details on contributing.

License
-------

[](#license)

JustEncrypt is released under the terms of the MIT license. See LICENCE.md for more information or see .

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~261 days

Total

4

Last Release

2612d ago

### Community

Maintainers

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

---

Top Contributors

[![KoltsovAnton](https://avatars.githubusercontent.com/u/24591641?v=4)](https://github.com/KoltsovAnton "KoltsovAnton (1 commits)")[![rubensayshi](https://avatars.githubusercontent.com/u/649160?v=4)](https://github.com/rubensayshi "rubensayshi (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/koltsov-justencrypt/health.svg)

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

###  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)[paragonie/paseto

Platform-Agnostic Security Tokens

3.4k1.3M18](/packages/paragonie-paseto)[paragonie/ciphersweet

Searchable field-level encryption library for relational databases

4641.2M21](/packages/paragonie-ciphersweet)[paragonie/certainty

Up-to-date, verifiable repository for Certificate Authorities

2642.4M20](/packages/paragonie-certainty)[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)
