1asn1js
2======
3
4asn1js is a JavaScript generic ASN.1 parser/decoder that can decode any valid ASN.1 DER or BER structures.
5
6An example page that can decode Base64-encoded (raw base64, PEM armoring and `begin-base64` are recognized) or Hex-encoded (or local files with some browsers) is included and can be used both [online on the official website](https://lapo.it/asn1js/) or [offline (ZIP file)](https://lapo.it/asn1js/asn1js.zip).
7
8Usage with `npm` / `yarn`
9-------------------------
10
11This package can be installed with either npm or yarn via the following commands:
12
13```sh
14npm install @lapo/asn1js
15# or with yarn
16yarn add @lapo/asn1js
17```
18
19Assuming a standard javascript bundler is setup you can import it like so:
20
21```js
22const ASN1 = require('@lapo/asn1js');
23// or with ES modules
24import ASN1 from '@lapo/asn1js';
25```
26
27A submodule of this package can also be imported:
28
29```js
30const Hex = require('@lapo/asn1js/hex');
31// or with ES modules
32import Hex from '@lapo/asn1js/hex';
33```
34
35Usage with RequireJS
36--------------------
37
38Can be [tested on JSFiddle](https://jsfiddle.net/lapo/tmdq35ug/).
39
40```html
41<script type="text/javascript" src="https://unpkg.com/requirejs/require.js"></script>
42<script>
43require([
44 'https://unpkg.com/@lapo/asn1js/asn1.js',
45 'https://unpkg.com/@lapo/asn1js/hex.js'
46], function(ASN1, Hex) {
47 document.body.innerText = ASN1.decode(Hex.decode('06032B6570')).content();
48});
49</script>
50```
51
52ISC license
53-----------
54
55ASN.1 JavaScript decoder Copyright (c) 2008-2022 Lapo Luchini <lapo@lapo.it>
56
57Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
58
59THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
60
61credits
62-------
63
64- OBJECT IDENTIFIER values are recognized using data taken from Peter Gutmann's [dumpasn1](https://www.cs.auckland.ac.nz/~pgut001/#standards) program.
65- BMPString support added by [Felipe Gasper](https://github.com/FGasper)
66- extended tag support added by [Péter Budai](https://www.peterbudai.eu/)
67- patches by [Gergely Nagy](https://github.com/ngg)
68- Relative OID support added by [Mistial Developer](https://github.com/mistial-dev)
69
70links
71-----
72
73- [official website](https://lapo.it/asn1js/)
74- [InDefero tracker](http://idf.lapo.it/p/asn1js/)
75- [GitHub mirror](https://github.com/lapo-luchini/asn1js)
76- [Ohloh code stats](https://www.openhub.net/p/asn1js)