---
title: "Sop/ASN1 PHP библиотека для Joomla - WebTolk"
description: "PHP библиотека для кодирования  и декодирования алгоритмов X.690 ASN.1 DER для Joomla 3 и Joomla 4"
url: "https://web-tolk.ru/dev/biblioteki/sop-asn1-php-library"
date: "2026-06-13T04:45:04+00:00"
language: "ru-RU"
---

# Sop/ASN1 PHP Library

- **Категории:** [Библиотеки](https://web-tolk.ru/dev/biblioteki), [Расширения для Joomla 4 - Joomla 6](https://web-tolk.ru/dev/rasshireniya-dlya-joomla-4)
- **Версия:** 4.1.1
- **Дата:** 17 марта 2022

4026 6107 CTR 66% Lib Free

[Скачать](https://web-tolk.ru/get?element=sop-asn1-library)[Версии](https://web-tolk.ru/dev/biblioteki/sop-asn1-php-library/versions)[GitHub](https://github.com/sop/asn1)

PHP библиотека для кодирования и декодирования алгоритмов X.690 ASN.1 DER для Joomla 3 и Joomla 4

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

## Описание

## Подключение PHP библиотеки ASN1 в Joomla

Пример кода для Joomla 3 и Joomla 4.

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

// Для Joomla 3

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

// ИЛИ
// для  Joomla 4
JLoader::registerNamespace('Sop', JPATH_LIBRARIES. '/Sop');
```

### Различия в указании namespaces в Joomla 3 и Joomla 4

В Joomla 3 следует указывать путь, после которого начинается namespace.

В Joomla 4 следует указывать путь вплоть до каталога, где начинается namespace.

## 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

 **Тип расширения:** Библиотека **Версия Joomla:** 4.0

## Что нового

 17.03.2022, 23:14:34

### SOP/ASN1 Library v.4.1.1

Версия от 17 февраля 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/",
                "name": "Главная"
            }
        },
        {
            "@type": "ListItem",
            "position": 2,
            "item": {
                "@id": "https://web-tolk.ru/dev",
                "name": "Расширения Joomla"
            }
        },
        {
            "@type": "ListItem",
            "position": 3,
            "item": {
                "@id": "/dev/biblioteki",
                "name": "Библиотеки"
            }
        },
        {
            "@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",
            "publisher": {
                "@id": "https://web-tolk.ru/#/schema/Organization/base"
            }
        },
        {
            "@type": "WebPage",
            "@id": "https://web-tolk.ru/#/schema/WebPage/base",
            "url": "https://web-tolk.ru/dev/biblioteki/sop-asn1-php-library",
            "name": "Sop/ASN1 PHP библиотека для Joomla - WebTolk",
            "description": "PHP библиотека для кодирования  и декодирования алгоритмов X.690 ASN.1 DER для Joomla 3 и Joomla 4",
            "isPartOf": {
                "@id": "https://web-tolk.ru/#/schema/WebSite/base"
            },
            "about": {
                "@id": "https://web-tolk.ru/#/schema/SoftwareApplication/base"
            },
            "inLanguage": "ru-RU",
            "breadcrumb": {
                "@id": "https://web-tolk.ru/#/schema/BreadcrumbList/17"
            }
        },
        {
            "@type": "SoftwareApplication",
            "name": "Sop/ASN1 PHP Library",
            "url": "https://web-tolk.ru/dev/biblioteki/sop-asn1-php-library",
            "description": "PHP библиотека для кодирования  и декодирования алгоритмов X.690 ASN.1 DER для Joomla 3 и Joomla 4",
            "applicationCategory": "Библиотеки",
            "softwareVersion": "4.1.1",
            "downloadUrl": "https://web-tolk.ru/get?element=sop-asn1-library",
            "image": "https://web-tolk.ru/images/swjprojects/projects/36/ru-RU/icon.jpg",
            "operatingSystem": "ANY",
            "interactionStatistic": [
                {
                    "@type": "InteractionCounter",
                    "interactionType": "https://schema.org/DownloadAction",
                    "userInteractionCount": 4026
                },
                {
                    "@type": "InteractionCounter",
                    "interactionType": "https://schema.org/ViewAction",
                    "userInteractionCount": 6108
                }
            ],
            "mainEntityOfPage": {
                "@type": "WebPage",
                "url": "https://web-tolk.ru/dev/biblioteki/sop-asn1-php-library"
            },
            "softwareRequirements": "Joomla",
            "applicationSubCategory": "Библиотеки, Расширения для Joomla 4 - Joomla 6",
            "isAccessibleForFree": true
        }
    ]
}
```
