---
title: "Sop/ASN1 PHP Library for Joomla - WebTolk websites development, Joomla Extensions"
description: "A PHP library for X.690 ASN.1 DER encoding and decoding for Joomla 3 and Joomla 4"
url: "https://web-tolk.ru/en/dev/biblioteki/sop-asn1-php-library"
date: "2026-06-13T03:17:07+00:00"
language: "en-GB"
---

# Sop/ASN1 PHP Library

- **Categories:** [Libraries](https://web-tolk.ru/en/dev/biblioteki), [Joomla 4 - Joomla 6extensions](https://web-tolk.ru/en/dev/rasshireniya-dlya-joomla-4)
- **Version:** 4.1.1
- **Date:** 17 March 2022

4026 6105 CTR 66% Lib Free

[Download](https://web-tolk.ru/en/get?element=sop-asn1-library)[Versions](https://web-tolk.ru/en/dev/biblioteki/sop-asn1-php-library/versions)[GitHub](https://github.com/sop/asn1)

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

![Sop/ASN1 PHP Library](https://web-tolk.ru/images/swjprojects/projects/36/en-GB/icon.jpg)

## Description

## Including ASN1 php library in Joomla

There is code example for Joomla 3 and Joomla 4.

```
<?php
defined('_JEXEC') or die('Restricted access');
use \Sop\ASN1\Element;
use \Sop\ASN1\Type\Constructed\Sequence;

// For Joomla 3

JLoader::registerNamespace('Sop', JPATH_LIBRARIES);

// OR
// for Joomla 4
JLoader::registerNamespace('Sop', JPATH_LIBRARIES. '/Sop');
```

## Joomla ASN1 PHP Library

A PHP library for X.690 Abstract Syntax Notation One (ASN.1) Distinguished Encoding Rules (DER) encoding and decoding.

## Requirements

- PHP >=7.2
- gmp
- mbstring

## Installation

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

```
composer require sop/asn1
```

## Usage

The general idea is that each ASN.1 type has its corresponding PHP class, that knows the details of encoding and decoding the specific type.

To decode DER data, use `fromDER` static method of the expected type. To encode object to DER, use `toDER` instance method.

Many methods return an `UnspecifiedType` object, that works as an intermediate wrapper with accessor methods ensuring type safety.

All objects are immutable and method chaining is promoted for the fluency of the API. Exception shall be thrown on errors.

## Code Examples

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

### Encode

Encode a sequence containing a UTF-8 string, an integer and an explicitly tagged object identifier, conforming to the following ASN.1 specification:

```
Example ::= SEQUENCE {
    greeting    UTF8String,
    answer      INTEGER,
    type    [1] EXPLICIT OBJECT IDENTIFIER
}
```

```
$seq = new Sequence(
    new UTF8String('Hello'),
    new Integer(42),
    new ExplicitlyTaggedType(
        1, new ObjectIdentifier('1.3.6.1.3'))
);
$der = $seq->toDER();
```

### Decode

Decode DER encoding from above.

```
$seq = UnspecifiedType::fromDER($der)->asSequence();
$greeting = $seq->at(0)->asUTF8String()->string();
$answer = $seq->at(1)->asInteger()->intNumber();
$type = $seq->at(2)->asTagged()->asExplicit()->asObjectIdentifier()->oid();
```

### Real-World Examples

See the following for more practical real-world usage examples.

- EC Private Key - [Decode](https://github.com/sop/crypto-types/blob/a27fa76d5f5e8c4596cb65a7be9d02a08421ba1e/lib/CryptoTypes/Asymmetric/EC/ECPrivateKey.php#L72) - [Encode](https://github.com/sop/crypto-types/blob/a27fa76d5f5e8c4596cb65a7be9d02a08421ba1e/lib/CryptoTypes/Asymmetric/EC/ECPrivateKey.php#L206)
- X.501 Attribute - [Decode](https://github.com/sop/x501/blob/c6bdb04673d5c04b9d49f83020e75b8ba7a20064/lib/X501/ASN1/Attribute.php#L55) - [Encode](https://github.com/sop/x501/blob/c6bdb04673d5c04b9d49f83020e75b8ba7a20064/lib/X501/ASN1/Attribute.php#L114)
- X.509 Certificate (`TBSCertificate` sequence) - [Decode](https://github.com/sop/x509/blob/f762c743b6930af4f45ef857ccc9f6199980a92e/lib/X509/Certificate/TBSCertificate.php#L130) - [Encode](https://github.com/sop/x509/blob/f762c743b6930af4f45ef857ccc9f6199980a92e/lib/X509/Certificate/TBSCertificate.php#L576)

## ASN.1 References

- [ITU-T X.690 07/2002](https://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf)
- [ITU-T X.690 08/2015](https://www.itu.int/rec/T-REC-X.690-201508-I/en)
- Hosted by [OSS Nokalva](http://www.oss.com/asn1/resources/books-whitepapers-pubs/asn1-books.html) - [ASN.1 — Communication Between Heterogeneous Systems by Olivier Dubuisson](http://www.oss.com/asn1/resources/books-whitepapers-pubs/dubuisson-asn1-book.PDF) - [ASN.1 Complete by Professor John Larmouth](http://www.oss.com/asn1/resources/books-whitepapers-pubs/larmouth-asn1-book.pdf)

## Joomla

 **Extension type:** Library **Joomla version:** 4.0

## What's new

 2022-03-17 23:14:34

### SOP/ASN1 Library v.4.1.1

Version from 17.02.2022

## JSON-LD Schema

```json
{
    "@context": "https://schema.org",
    "@type": "BreadcrumbList",
    "@id": "https://web-tolk.ru/#/schema/BreadcrumbList/17",
    "itemListElement": [
        {
            "@type": "ListItem",
            "position": 1,
            "item": {
                "@id": "https://web-tolk.ru/en",
                "name": "Home"
            }
        },
        {
            "@type": "ListItem",
            "position": 2,
            "item": {
                "@id": "https://web-tolk.ru/en/dev",
                "name": "Joomla extensions"
            }
        },
        {
            "@type": "ListItem",
            "position": 3,
            "item": {
                "@id": "/en/dev/biblioteki",
                "name": "Libraries"
            }
        },
        {
            "@type": "ListItem",
            "position": 4,
            "item": {
                "name": "Sop/ASN1 PHP Library"
            }
        }
    ]
}
```

```json
{
    "@context": "https://schema.org",
    "@graph": [
        {
            "@type": "Organization",
            "@id": "https://web-tolk.ru/#/schema/Organization/base",
            "name": "WebTolk",
            "url": "https://web-tolk.ru/",
            "logo": {
                "@type": "ImageObject",
                "@id": "https://web-tolk.ru/#/schema/ImageObject/logo",
                "url": "images/webtolk-1080p.jpg",
                "contentUrl": "images/webtolk-1080p.jpg",
                "width": 1920,
                "height": 1080
            },
            "image": {
                "@id": "https://web-tolk.ru/#/schema/ImageObject/logo"
            },
            "sameAs": [
                "https://github.com/WebTolk",
                "https://github.com/sergeytolkachyov",
                "https://vk.com/web_tolk",
                "https://vk.com/webtolkru",
                "https://tenchat.ru/sergeytolkachyov",
                "https://t.me/sergeytolkachyov",
                "https://t.me/webtolkru"
            ]
        },
        {
            "@type": "WebSite",
            "@id": "https://web-tolk.ru/#/schema/WebSite/base",
            "url": "https://web-tolk.ru/",
            "name": "WebTolk websites development, Joomla Extensions",
            "publisher": {
                "@id": "https://web-tolk.ru/#/schema/Organization/base"
            }
        },
        {
            "@type": "WebPage",
            "@id": "https://web-tolk.ru/#/schema/WebPage/base",
            "url": "https://web-tolk.ru/en/dev/biblioteki/sop-asn1-php-library",
            "name": "Sop/ASN1 PHP Library for Joomla - WebTolk websites development, Joomla Extensions",
            "description": "A PHP library for X.690 ASN.1 DER encoding and decoding for Joomla 3 and Joomla 4",
            "isPartOf": {
                "@id": "https://web-tolk.ru/#/schema/WebSite/base"
            },
            "about": {
                "@id": "https://web-tolk.ru/#/schema/SoftwareApplication/base"
            },
            "inLanguage": "en-GB",
            "breadcrumb": {
                "@id": "https://web-tolk.ru/#/schema/BreadcrumbList/17"
            }
        },
        {
            "@type": "SoftwareApplication",
            "name": "Sop/ASN1 PHP Library",
            "url": "https://web-tolk.ru/en/dev/biblioteki/sop-asn1-php-library",
            "description": "A PHP library for X.690 ASN.1 DER encoding and decoding for Joomla 3 and Joomla 4",
            "applicationCategory": "Libraries",
            "softwareVersion": "4.1.1",
            "downloadUrl": "https://web-tolk.ru/en/get?element=sop-asn1-library",
            "image": "https://web-tolk.ru/images/swjprojects/projects/36/en-GB/icon.jpg",
            "operatingSystem": "ANY",
            "interactionStatistic": [
                {
                    "@type": "InteractionCounter",
                    "interactionType": "https://schema.org/DownloadAction",
                    "userInteractionCount": 4026
                },
                {
                    "@type": "InteractionCounter",
                    "interactionType": "https://schema.org/ViewAction",
                    "userInteractionCount": 6106
                }
            ],
            "mainEntityOfPage": {
                "@type": "WebPage",
                "url": "https://web-tolk.ru/en/dev/biblioteki/sop-asn1-php-library"
            },
            "softwareRequirements": "Joomla",
            "applicationSubCategory": "Libraries, Joomla 4 - Joomla 6extensions",
            "isAccessibleForFree": true
        }
    ]
}
```
