PHPackages                             ahtishamashraf/astra512-ffi - 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. ahtishamashraf/astra512-ffi

ActiveLibrary[Security](/categories/security)

ahtishamashraf/astra512-ffi
===========================

PHP FFI bindings for ASTRA-512 (research SIV-style AEAD) with key management helpers.

v0.1.1(8mo ago)01MITPHPPHP &gt;=8.1

Since Aug 20Pushed 8mo agoCompare

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

READMEChangelogDependencies (1)Versions (2)Used By (0)

FFI bindings for **ASTRA-512** (research SIV-style AEAD) with **key management** and **password-based key derivation** helpers.

> ⚠️ This is *research cryptography*. Do not use in production until independent review.

Install
-------

[](#install)

```
composer require ahtishamashraf/astra512-ffi
```

Native library
--------------

[](#native-library)

The FFI loader searches:

1. explicit path you pass to `Astra512::create($path)`
2. `ASTRA512_LIB` env var (absolute path)
3. vendored `bin//`
4. system names: `libastra512.so` / `libastra512.dylib` / `astra512.dll`

Use with a **random 32-byte key**
---------------------------------

[](#use-with-a-random-32-byte-key)

```
use Astra512\Astra512;
use Astra512\Key;

$astra = Astra512::create(getenv('ASTRA512_LIB') ?: null);
$key = Key::generate();                   // 32 random bytes
$aad = "app:v1";
$pt  = "hello";

[$ct, $tag] = $astra->encrypt($key, $aad, $pt);
$out = $astra->decrypt($key, $aad, $ct, $tag);
```

Use with a **password** (derives a 32-byte key via Argon2id)
------------------------------------------------------------

[](#use-with-a-password-derives-a-32-byte-key-via-argon2id)

```
use Astra512\Astra512;
use Astra512\Password;

$astra = Astra512::create(getenv('ASTRA512_LIB') ?: null);
$password = "correct horse battery staple";
[$salt, $key] = Password::deriveKey($password);   // returns [16-byte salt, 32-byte key]

[$ct, $tag] = $astra->encrypt($key, "app:v1", "secret");

// To decrypt later, re-derive the key with the saved salt:
$key2 = Password::deriveKeyWithSalt($password, $salt);
$out  = $astra->decrypt($key2, "app:v1", $ct, $tag);
```

### About *salt*

[](#about-salt)

- **Encryption itself does not need a salt or nonce** (ASTRA-512 is SIV-style and deterministic).
- **Salt is only for password-based key derivation** (Argon2id). Store the salt alongside the ciphertext so you can re-derive the same key to decrypt.

Helpers
-------

[](#helpers)

- `Key::generate()` → 32 random bytes
- `Key::save($path, $key)` / `Key::load($path)`
- `Password::deriveKey($password, $opslimit=?, $memlimit=?)` → returns `[salt, key]`
- `Password::deriveKeyWithSalt($password, $salt, ...)` → returns `key`

See `examples/` for complete flows.

astra512-ffi
============

[](#astra512-ffi)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance58

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity34

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

266d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/891b734f83d1ba6c589ee96f1e9834806e3200dfe2ef5725a7ef8448449bd4dc?d=identicon)[ahtishamashraf](/maintainers/ahtishamashraf)

---

Tags

cryptoaeadffiastra512siv

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ahtishamashraf-astra512-ffi/health.svg)

```
[![Health](https://phpackages.com/badges/ahtishamashraf-astra512-ffi/health.svg)](https://phpackages.com/packages/ahtishamashraf-astra512-ffi)
```

###  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)[spatie/crypto

Encrypting and signing data using private/public keys

486763.5k10](/packages/spatie-crypto)[aplus/crypto

Aplus Framework Crypto Library

161.6M1](/packages/aplus-crypto)[ionux/phactor

Phactor is a high-performance PHP implementation of the elliptic curve math functions required to generate &amp; verify private/public (asymmetric) EC keypairs and ECDSA signatures based on secp256k1 curve parameters. This library also includes a class to generate Service Identification Numbers (SINs) based on the published Identity Protocol v1 spec.

5275.0k30](/packages/ionux-phactor)[cryptapi/php-cryptapi

CryptAPI's PHP library

2211.6k](/packages/cryptapi-php-cryptapi)

PHPackages © 2026

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