PHPackages                             cymapgt/asn1 - 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. cymapgt/asn1

ActiveLibrary

cymapgt/asn1
============

An ASN.1 library for PHP.

0.2.1(7y ago)1572MITPHPPHP &gt;=7.0

Since Apr 14Pushed 7y ago1 watchersCompare

[ Source](https://github.com/cymapgt/ASN1)[ Packagist](https://packagist.org/packages/cymapgt/asn1)[ Docs](https://github.com/FreeDSx/ASN1)[ RSS](/packages/cymapgt-asn1/feed)WikiDiscussions master Synced today

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

FreeDSx ASN1 [![Build Status](https://camo.githubusercontent.com/535f707aeb3c7792a8071d608194e50190e1e486d7eb510a0905ade5b9ac1abe/68747470733a2f2f7472617669732d63692e6f72672f467265654453782f41534e312e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/FreeDSx/ASN1) [![AppVeyor Build Status](https://camo.githubusercontent.com/9e027deaf5739e20af8a469667f20b53773f9be6618a83eb0c5a6398e87f67ce/68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f6769746875622f667265656473782f61736e313f6272616e63683d6d6173746572267376673d74727565)](https://ci.appveyor.com/project/ChadSikorra/asn1)
===============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#freedsx-asn1--)

FreeDSx ASN1 is a PHP library for dealing with ASN.1 data structures. Its original focus was on ASN.1 BER encoding used in LDAP as part of the FreeDSx LDAP library. It was moved to its own library to allow for additional encoders and reuse in other projects.

Getting Started
===============

[](#getting-started)

Install via composer:

```
composer require freedsx/asn1
```

Encoding
--------

[](#encoding)

To encode an ASN.1 structure you can use the helper methods of the Asn1 class and an encoder:

```
use FreeDSx\Asn1\Asn1;
use FreeDSx\Asn1\Encoders;

# Create the ASN.1 structure you need...
$asn1 = Asn1::sequence(
    Asn1::integer(9999),
    Asn1::octetString('foo'),
    Asn1::boolean(true)
);

# Encoded $bytes will now contain the BER binary representation of a sequence containing:
#  - An integer type of value 9999
#  - An octet string type of value 'foo'
#  - A boolean type of true
$bytes = Encoders::ber()->encode($asn1);

# Encode using the more strict DER encoder
$bytes = Encoders::der()->encode($asn1);
```

Decoding
--------

[](#decoding)

To decode an ASN.1 structure you can get an encoder and call decode then parse it out:

```
use FreeDSx\Asn1\Asn1;
use FreeDSx\Asn1\Encoders;
use FreeDSx\Asn1\Type\SequenceType;
use FreeDSx\Asn1\Type\OctetStringType;
use FreeDSx\Asn1\Type\IntegerType;
use FreeDSx\Asn1\Type\BooleanType;

# Assuming bytes contains the binary BER encoded sequence described in the encoding section
# Get a BER encoder instance, call decode on it, and $pdu will now be a sequence object.
$pdu = Encoders::ber()->decode($bytes);

# You could also decode using DER, if that's what you're expecting...
$pdu = Encoders::der()->decode($bytes);

# Validate the structure you are expecting...
if (!($pdu instanceof SequenceType && count($pdu) === 3)) {
    echo "Decoded structure is invalid.".PHP_EOL;
    exit;
}

# Loop through the sequence and check the individual types it contains...
foreach ($pdu as $i => $type) {
    if ($i === 0 && $type instanceof IntegerType) {
        var_dump($type->getValue());
    } elseif ($i === 1 && $type instanceof OctetStringType) {
        var_dump($type->getValue());
    } elseif ($i === 2 && $type instanceof BooleanType) {
        var_dump($type->getValue());
    } else {
        echo "Invalid type encountered.".PHP_EOL;
        exit;
    }
}
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.1% 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 ~10 days

Total

6

Last Release

2899d ago

PHP version history (2 changes)0.1.0PHP &gt;=7.1

0.1.3PHP &gt;=7.0

### Community

Maintainers

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

---

Top Contributors

[![ChadSikorra](https://avatars.githubusercontent.com/u/388229?v=4)](https://github.com/ChadSikorra "ChadSikorra (41 commits)")[![cymapgt](https://avatars.githubusercontent.com/u/12482626?v=4)](https://github.com/cymapgt "cymapgt (4 commits)")

---

Tags

asn1DERx690ber

### Embed Badge

![Health badge](/badges/cymapgt-asn1/health.svg)

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

###  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)[spomky-labs/pki-framework

A PHP framework for managing Public Key Infrastructures. It comprises X.509 public key certificates, attribute certificates, certification requests and certification path validation.

2725.9M11](/packages/spomky-labs-pki-framework)[sop/asn1

A PHP library for X.690 ASN.1 DER encoding and decoding.

601.7M39](/packages/sop-asn1)[freedsx/asn1

An ASN.1 library for PHP.

15216.5k9](/packages/freedsx-asn1)[kelunik/certificate

Access certificate details and transform between different formats.

10938.3M8](/packages/kelunik-certificate)[falseclock/advanced-cms

A PHP Library that allows you to decode and manipulate CAdES or in other words CMS Advanced Electronic Signatures described in ETSI standart TS 101 733.

223.2k](/packages/falseclock-advanced-cms)

PHPackages © 2026

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