sop/asn1
Composer 安装命令:
composer require sop/asn1
包简介
A PHP library for X.690 ASN.1 DER encoding and decoding.
README 文档
README
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.
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
- X.501 Attribute
- X.509 Certificate (
TBSCertificatesequence)
ASN.1 References
License
This project is licensed under the MIT License.
sop/asn1 适用场景与选型建议
sop/asn1 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.83M 次下载、GitHub Stars 达 60, 最近一次更新时间为 2016 年 04 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「asn1」 「asn.1」 「DER」 「x690」 「x.690」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sop/asn1 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sop/asn1 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sop/asn1 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
An ASN.1 library for PHP.
OCR PDF's and images with the OCR.Space API from Laravel
A PHP Framework that allows you to encode and decode arbitrary ASN.1 structures using the ITU-T X.690 Encoding Rules.
A PHP Library that allows you to decode ASN.1 CMS using Basic Encoding Rules (BER).
A PHP Framework that allows you to encode and decode arbitrary ASN.1 structures using the ITU-T X.690 Encoding Rules.
PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.
统计信息
- 总下载量: 1.83M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 62
- 点击次数: 34
- 依赖项目数: 46
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-04-12