PHPackages                             sop/aes-kw - 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. sop/aes-kw

ActiveLibrary

sop/aes-kw
==========

A PHP library for AES Key Wrap algorithm with padding support.

3.0.0(6y ago)2260.2k↓31.8%1MITPHPPHP &gt;=7.2

Since Apr 19Pushed 6y ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (10)Used By (1)

AES Key Wrap
============

[](#aes-key-wrap)

[![Build Status](https://camo.githubusercontent.com/97f3f917e2c17172b732dc9f5821cc2904e49e02d4d49e4abffecbd622f1b062/68747470733a2f2f7472617669732d63692e6f72672f736f702f6165732d6b772e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/sop/aes-kw)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/949a2e4fa6c9a77aa9f427963f49faa93a275fe414abe4b501b22ec59ba7b8da/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f736f702f6165732d6b772f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/sop/aes-kw/?branch=master)[![Coverage Status](https://camo.githubusercontent.com/e56723a6e812fb5f02dff6a5e4d1f52c68ac87e320cf145613c755b1328d5004/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f736f702f6165732d6b772f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/sop/aes-kw?branch=master)[![License](https://camo.githubusercontent.com/3d7089b1544f151ef7b16b683a9876132b7370fdcdfb127afaa78da4cbcd7eb0/68747470733a2f2f706f7365722e707567782e6f72672f736f702f6165732d6b772f6c6963656e7365)](https://github.com/sop/aes-kw/blob/master/LICENSE)

A PHP library for AES Key Wrap ([RFC 3394](https://tools.ietf.org/html/rfc3394)) algorithm with padding ([RFC 5649](https://tools.ietf.org/html/rfc5649)) support.

Supports AES key sizes of 128, 192 and 256 bits.

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

[](#requirements)

- PHP &gt;=7.2
- openssl
- hash

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

[](#installation)

This library is available on [Packagist](https://packagist.org/packages/sop/aes-kw).

```
composer require sop/aes-kw

```

Code examples
-------------

[](#code-examples)

Here are some simple usage examples. Namespaces are omitted for brevity.

### Wrap a 128 bit key with AES-128

[](#wrap-a-128-bit-key-with-aes-128)

Wrap a key of 16 bytes using a 16-byte key encryption key.

```
$kek = '0123456789abcdef'; // 128-bit key encryption key
$key = 'MySecretPassword'; // key to encrypt
$algo = new AESKW128();
$ciphertext = $algo->wrap($key, $kek);
echo bin2hex($ciphertext);
```

Outputs:

```
89efdbc3501f1f5e952a4bbae1329c9f1a47b9fd61b48dee

```

### Unwrap a key

[](#unwrap-a-key)

Unwrap a key from previous example. `$kek` and `$algo` variables are the same. `$ciphertext` variable contains the output from a wrapping procedure.

```
$key = $algo->unwrap($ciphertext, $kek);
echo $key;
```

Outputs:

```
MySecretPassword

```

### Wrap an arbitrary length passphrase with AES-192

[](#wrap-an-arbitrary-length-passphrase-with-aes-192)

Wrapping a key that is not a multiple of 64 bits requires padding.

```
$kek = '012345678901234567890123'; // 192-bit key encryption key
$key = 'My hovercraft is full of eels.'; // passphrase to encrypt
$algo = new AESKW192();
$ciphertext = $algo->wrapPad($key, $kek);
echo bin2hex($ciphertext);
```

Outputs:

```
f319811450badfe4385b5534bf26fa6f9fdcd1a593b3ae6b707f15c1015bbf3faf58619818bd8784

```

### Unwrap a key with padding

[](#unwrap-a-key-with-padding)

Key that was wrapped with padding must be unwrapped with `unwrapPad`.

```
$key = $algo->unwrapPad($ciphertext, $kek);
echo $key;
```

Outputs:

```
My hovercraft is full of eels.

```

License
-------

[](#license)

This project is licensed under the MIT License.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

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

Recently: every ~270 days

Total

8

Last Release

2553d ago

Major Versions

1.0.5 → 2.0.02017-11-28

2.0.0 → 3.0.02019-05-23

PHP version history (3 changes)1.0.0PHP &gt;=5.6.3

2.0.0PHP &gt;=7.0

3.0.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/35cf70dd6be68d37fd42490e3ad9c199d2a1f1dd4420f71658998b7d8b694e97?d=identicon)[sop](/maintainers/sop)

---

Top Contributors

[![sop](https://avatars.githubusercontent.com/u/1017000?v=4)](https://github.com/sop "sop (55 commits)")

---

Tags

aesaes-key-wrapkey-wrappingaeskey wrapaes key wrap

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sop-aes-kw/health.svg)

```
[![Health](https://phpackages.com/badges/sop-aes-kw/health.svg)](https://phpackages.com/packages/sop-aes-kw)
```

###  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)[spomky-labs/aes-key-wrap

AES Key Wrap for PHP.

5022.7M14](/packages/spomky-labs-aes-key-wrap)[spomky-labs/php-aes-gcm

AES GCM (Galois Counter Mode) PHP implementation.

724.9M20](/packages/spomky-labs-php-aes-gcm)[nzo/url-encryptor-bundle

The NzoUrlEncryptorBundle is a Symfony Bundle used to Encrypt and Decrypt data and variables in the Web application or passed through URL

961.0M2](/packages/nzo-url-encryptor-bundle)[mmeyer2k/dcrypt

A petite library of encryption functionality for PHP

98727.2k1](/packages/mmeyer2k-dcrypt)

PHPackages © 2026

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