Installations
npm install asn1.js
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
13.9.0
NPM Version
6.13.7
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
indutny
Download Statistics
Total Downloads
3,473,775,029
Last Day
1,977,908
Last Week
8,850,238
Last Month
39,856,988
Last Year
538,838,901
GitHub Statistics
186 Stars
232 Commits
64 Forks
13 Watching
6 Branches
21 Contributors
Package Meta Information
Latest Version
5.4.1
Package Id
asn1.js@5.4.1
Size
13.23 kB
NPM Version
6.13.7
Node Version
13.9.0
Publised On
18 Jun 2020
Total Downloads
Cumulative downloads
Total Downloads
3,473,775,029
Last day
-3.7%
1,977,908
Compared to previous day
Last week
-15.4%
8,850,238
Compared to previous week
Last month
5.2%
39,856,988
Compared to previous month
Last year
-6.7%
538,838,901
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
4
ASN1.js
ASN.1 DER Encoder/Decoder and DSL.
Example
Define model:
1var asn = require('asn1.js'); 2 3var Human = asn.define('Human', function() { 4 this.seq().obj( 5 this.key('firstName').octstr(), 6 this.key('lastName').octstr(), 7 this.key('age').int(), 8 this.key('gender').enum({ 0: 'male', 1: 'female' }), 9 this.key('bio').seqof(Bio) 10 ); 11}); 12 13var Bio = asn.define('Bio', function() { 14 this.seq().obj( 15 this.key('time').gentime(), 16 this.key('description').octstr() 17 ); 18});
Encode data:
1var output = Human.encode({ 2 firstName: 'Thomas', 3 lastName: 'Anderson', 4 age: 28, 5 gender: 'male', 6 bio: [ 7 { 8 time: +new Date('31 March 1999'), 9 description: 'freedom of mind' 10 } 11 ] 12}, 'der');
Decode data:
1var human = Human.decode(output, 'der'); 2console.log(human); 3/* 4{ firstName: <Buffer 54 68 6f 6d 61 73>, 5 lastName: <Buffer 41 6e 64 65 72 73 6f 6e>, 6 age: 28, 7 gender: 'male', 8 bio: 9 [ { time: 922820400000, 10 description: <Buffer 66 72 65 65 64 6f 6d 20 6f 66 20 6d 69 6e 64> } ] } 11*/
Partial decode
Its possible to parse data without stopping on first error. In order to do it, you should call:
1var human = Human.decode(output, 'der', { partial: true }); 2console.log(human); 3/* 4{ result: { ... }, 5 errors: [ ... ] } 6*/
LICENSE
This software is licensed under the MIT License.
Copyright Fedor Indutny, 2017.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
no binaries found in the repo
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 2/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 2 are checked with a SAST tool
Reason
18 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-6chw-6frg-f759
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-2j2x-2gpw-g8fm
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
- Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9
Score
1.7
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to asn1.js
@panva/asn1.js
ASN.1 encoder and decoder for Node.js with no dependencies (fork of asn1.js using native BigInt)
asn1.js-rfc2560
RFC2560 structures for asn1.js
asn1.js-rfc5280
RFC5280 extension structures for asn1.js
@peculiar/asn1-android
[![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://raw.githubusercontent.com/PeculiarVentures/asn1-schema/master/packages/android/LICENSE.md) [![npm version](https://badge.fury.io/js/%40peculiar%2Fasn1-android.svg)](https: