PHPackages                             ialopezg/encryption - 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. ialopezg/encryption

ActiveLibrary[Security](/categories/security)

ialopezg/encryption
===================

Encryption Library for PHP

v0.0.1(5y ago)02MITPHPPHP &gt;=5.6

Since Sep 24Pushed 5y ago1 watchersCompare

[ Source](https://github.com/ialopezg/encryption)[ Packagist](https://packagist.org/packages/ialopezg/encryption)[ RSS](/packages/ialopezg-encryption/feed)WikiDiscussions master Synced 1w ago

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

Cryptography Library
====================

[](#cryptography-library)

 [![Version](https://camo.githubusercontent.com/81896cb96c718e0cea7c77c76e63713d274ad9cb4e224a2aed0c43a3b90f1c20/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f69616c6f70657a672f656e6372797074696f6e2e7376673f6c6162656c3d76657273696f6e26636f6c6f723d677265656e)](https://github.com/ialopezg/encryption/releases) [![License](https://camo.githubusercontent.com/0cb650cae5fbc5287da2a5e73501fac11b3fd01c715f9b8045ac852e1246e241/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f636f6c6f723d677265656e)](https://github.com/ialopezg/encryption/blob/master/LICENSE) [![Total downloads](https://camo.githubusercontent.com/d68e98f7c0662b95054f8611440bcbca96d19f5befb90dcc00bbda91917a6ef8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f69616c6f70657a672f656e6372797074696f6e2f746f74616c2e7376673f636f6c6f723d677265656e)](https://github.com/ialopezg/encryption)

Cryptography Library for PHP

**Table of Contents**

- [Installation](#installation)
- [Features](#features)
- [Requirements](#requirements)
- [Usage instructions](#usage-instructions)
- [License](#license)

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

[](#installation)

1. Package manager

    - Composer ```
        composer require ialopezg/encryption
        ```
2. Manually

    - **Github**```
        git clone https://github.com/ialopezg/encryption
        ```

Features
--------

[](#features)

LibraryDescription[`Password`](#iteratorobject)Library for password manipulation.Requirements
------------

[](#requirements)

- **PHP** *v5.6+*
- **ext-mbstring** PHP extension
- **ext-openssl** PHP extension
- **ialopezg/core** *v0.0.1+*
- **ialopezg/logger** *v0.0.4+*

Usage instructions
------------------

[](#usage-instructions)

### IteratorObject

[](#iteratorobject)

### Methods

[](#methods)

MethodDescription[`createKey()`](#password_createKey)Creates a random key with the lengh provided. Optional the result could be returned with capital letters.[`getOption()`](#password_getOption)Gets an option value. If value does not exists will return the default value.[`hash()`](#password_hash)Encrypts a simple text password into a ciphered password.[`setOption()`](#password_setOption)Sets an option value.[`verify()`](#password_verify)Encrypts a plain text into cipher text.#### Method Details

[](#method-details)

#####  Method: `createdKey()`

[](#-method-createdkey)

```
/**
 * Creates a random key with the length specified. Optional the result could be returned with capital letters.
 *
 * @param int $length       Output length.
 * @param bool $capitalize  Whether if the result key will be returned with capital letters.
 *
 * @throws Exception If it was not possible to gather sufficient entropy.
 * @return string A random key.
 */
public static function createKey($length, $capitalize = false): string
```

**Examples**

```
$key = \ialopezg\Libraries\Encryption\Password::createKey(8, true);

// Display the encryption key string
echo "Encryption key: {$key}";
```

#####  Method: `getOption()`

[](#-method-getoption)

```
/**
 * Gets an option value. If value does not exists will return the default value.
 *
 * @param string $key Option key name.
 * @param null $default Option default value.
 *
 * @return mixed
 */
public function getOption($key, $default = null): string
```

**Examples**

```
$encrypter->setOption('key', Password::createKey(8, true);

// Display the encryption key string
echo "Encryption key: {$encrypter->getOption('key')}";
```

#####  Method: `hash()`

[](#-method-hash)

```
/**
 * Encrypts a simple text password into a ciphered password.
 *
 * @param string $password Plain text password.
 *
 * @return string Ciphered password.
 * @throws Exception If data provided is not a string.
 */
public function hash($password): string
```

**Examples**

```
$encrypter = new \ialopezg\Libraries\Encryption\Password([
    'cipher' => 'AES-128-CTR',
    'digest' => 'SHA512',
    'options' => OPENSSL_CIPHER_RC2_40,
    'key' => 'YOUR_SECRET_KEY'
]);
$encrypted_password = $encrypter->encrypt($password);

// Display the encrypted string
echo "Encrypted password: {$encrypted_password}";
```

#####  Method: `setOption()`

[](#-method-setoption)

```
/**
 * Sets an option value.
 *
 * @param string $key Option key name.
 * @param mixed $value Option value.
 *
 * @return void
 */
public function setOption($key, $value): string
```

**Examples**

```
$encrypter = new \ialopezg\Libraries\Encryption\Password();
$encrypter->setOption('key', $key);
```

#####  Method: `verify()`

[](#-method-verify)

```
/**
 * Verifies if a hashed password is equal to the plain tex provided.
 *
 * @param string $password Plain text password.
 * @param string $hash Ciphered text
 *
 * @return bool true If password equals to hash, false otherwise.
 * @throws Exception If data provided is not a string.
 */
public function verify($password, $hash): bool
```

**Examples**

```
$encrypter = new \ialopezg\Libraries\Encryption\Password();

$password = 'YOUR_PASSWORD';
$encrypted_password = 'YOUR_ENCRYPTED_PASSWORD';

// Display the encrypted string
echo 'Password are equals: ' . ($encrypter->verify($password, $encrypted_password) ? 'true' : 'false') . '';
```

For more examples or options, see [examples](examples) directory. For live examples, run:

```
### linux bash
./server.sh
```

or

```
### windows prompt
server.bat
```

License
-------

[](#license)

This project is under the MIT license. For more information see [LICENSE](https://github.com/ialopezg/core/blob/master/LICENSE).

Copyright (c) [Isidro A. López G.](https://ialopezg.com/)

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

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

Unknown

Total

1

Last Release

2063d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7f97c20d9309952abd3cadf77f087307284d35ae6c484de3441eec36dbd5c93c?d=identicon)[ialopezg](/maintainers/ialopezg)

### Embed Badge

![Health badge](/badges/ialopezg-encryption/health.svg)

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

###  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)
