71 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			71 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<!DOCTYPE html>
 | 
						|
<html>
 | 
						|
<head>
 | 
						|
  <title>ASN.1 Parser - Bluecrypt</title>
 | 
						|
  <style>
 | 
						|
    textarea {
 | 
						|
      width: 42em;
 | 
						|
      height: 10em;
 | 
						|
    }
 | 
						|
  </style>
 | 
						|
</head>
 | 
						|
<body>
 | 
						|
  <h1>Bluecrypt ASN.1 Parser</h1>
 | 
						|
 | 
						|
  <h2>PEM (base64-encoded DER)</h2>
 | 
						|
  <textarea class="js-input" placeholder="Paste a PEM here">-----BEGIN PUBLIC KEY-----
 | 
						|
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEIT1SWLxsacPiE5Z16jkopAn8/+85
 | 
						|
rMjgyCokrnjDft6Y/YnA4A50yZe7CnFsqeDcpnPbubP6cpYiVcnevNIYyg==
 | 
						|
-----END PUBLIC KEY-----</textarea>
 | 
						|
 | 
						|
  <h2>Hex</h2>
 | 
						|
  <pre><code class="js-hex"> </code></pre>
 | 
						|
 | 
						|
  <h2>ASN.1 Array</h2>
 | 
						|
  <pre><code class="js-array"> </code></pre>
 | 
						|
 | 
						|
  <h2>ASN.1 Object</h2>
 | 
						|
  <pre><code class="js-json"> </code></pre>
 | 
						|
 | 
						|
  <br>
 | 
						|
  <p>Made with <a href="https://git.coolaj86.com/coolaj86/asn1-parser/">asn1-parser.js</a></p>
 | 
						|
 | 
						|
  <script src="./asn1-parser.js"></script>
 | 
						|
  <script>
 | 
						|
    var $input = document.querySelector('.js-input');
 | 
						|
 | 
						|
    function toArray(next) {
 | 
						|
      console.log(next);
 | 
						|
      if (next.value) {
 | 
						|
        return [next.type, Enc.bufToHex(next.value)];
 | 
						|
      }
 | 
						|
      return [next.type, next.children.map(function (child) {
 | 
						|
        return toArray(child);
 | 
						|
      })];
 | 
						|
    }
 | 
						|
 | 
						|
    function convert() {
 | 
						|
      console.log('keyup');
 | 
						|
      var json;
 | 
						|
 | 
						|
      try {
 | 
						|
        var pem = PEM.parseBlock(document.querySelector('.js-input').value);
 | 
						|
        var hex = Enc.bufToHex(pem.der);
 | 
						|
        var arr = [];
 | 
						|
        document.querySelector('.js-hex').innerText = hex
 | 
						|
          .match(/.{2}/g).join(' ').match(/.{1,24}/g).join(' ').match(/.{1,50}/g).join('\n');
 | 
						|
        json = ASN1.parse(pem.der);
 | 
						|
      } catch(e) {
 | 
						|
        json = { error: { message: e.message } };
 | 
						|
      }
 | 
						|
 | 
						|
      document.querySelector('.js-json').innerText = JSON.stringify(json, ASN1._replacer, 2);
 | 
						|
      document.querySelector('.js-array').innerText = JSON.stringify(toArray(json), null, 2);
 | 
						|
    }
 | 
						|
 | 
						|
    $input.addEventListener('keyup', convert);
 | 
						|
    convert();
 | 
						|
  </script>
 | 
						|
</body>
 | 
						|
</html>
 |