PHPackages                             paragonie/hpke - 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. paragonie/hpke

ActiveLibrary[Security](/categories/security)

paragonie/hpke
==============

Hybrid Public-Key Encryption (RFC 9180) for PHP

v0.6.0(1mo ago)822.8k↓14.4%3[1 issues](https://github.com/paragonie/hpke-php/issues)1ISCPHPPHP ^8.2CI passing

Since Feb 4Pushed 1mo ago4 watchersCompare

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

READMEChangelog (6)Dependencies (9)Versions (11)Used By (1)

Hybrid Public-Key Encryption (HPKE, RFC 9180) for PHP
=====================================================

[](#hybrid-public-key-encryption-hpke-rfc-9180-for-php)

[![Build Status](https://github.com/paragonie/hpke-php/actions/workflows/test.yml/badge.svg)](https://github.com/paragonie/hpke-php/actions)[![Latest Stable Version](https://camo.githubusercontent.com/e28e948bda5695444ffe803714f5fbf266cdfe2fe67ed4534ac58d2999fc795e/68747470733a2f2f706f7365722e707567782e6f72672f70617261676f6e69652f68706b652f762f737461626c65)](https://packagist.org/packages/paragonie/hpke)[![Total Downloads](https://camo.githubusercontent.com/9d922f67042038a47630baa1790ca11483d8d27d28cda3f04d82bd596d24e31c/68747470733a2f2f706f7365722e707567782e6f72672f70617261676f6e69652f68706b652f646f776e6c6f616473)](https://packagist.org/packages/paragonie/hpke)[![Latest Unstable Version](https://camo.githubusercontent.com/d4331808c6be7226881b0ff5f4496718710c4edcd3e8d8f1681bddc16c41e3e3/68747470733a2f2f706f7365722e707567782e6f72672f70617261676f6e69652f68706b652f762f756e737461626c65)](https://packagist.org/packages/paragonie/hpke)[![License](https://camo.githubusercontent.com/4c11f9e7117b1aa87db538379d283324d486a3057704e9b1c17f7471632b7900/68747470733a2f2f706f7365722e707567782e6f72672f70617261676f6e69652f68706b652f6c6963656e7365)](https://packagist.org/packages/paragonie/hpke)

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

[](#installation)

```
composer require paragonie/hpke

```

Usage
-----

[](#usage)

### Instantiating HPKE

[](#instantiating-hpke)

First, you need to decide on an HPKE ciphersuite. You can build these yourself by component, or use the standard modes that ship with [RFC 9180](https://www.rfc-editor.org/rfc/rfc9180.html#name-iana-considerations):

- DHKEM(X25519, HKDF-SHA256), HKDF-SHA256, AES-128-GCM
- DHKEM(X25519, HKDF-SHA256), HKDF-SHA256, ChaCha20Poly1305
- DHKEM(P-256, HKDF-SHA256), HKDF-SHA256, AES-128-GCM
- DHKEM(P-256, HKDF-SHA256), HKDF-SHA512, AES-128-GCM
- DHKEM(P-256, HKDF-SHA256), HKDF-SHA256, ChaCha20Poly1305
- DHKEM(P-521, HKDF-SHA512), HKDF-SHA512, AES-256-GCM

To instantiate one of these ciphersuites, you can use the Factory class, like so:

```
