asn1-parser.js/index.html

53 lines
1.4 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>
<textarea class="js-input" placeholder="Paste a PEM here">-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEIT1SWLxsacPiE5Z16jkopAn8/+85
rMjgyCokrnjDft6Y/YnA4A50yZe7CnFsqeDcpnPbubP6cpYiVcnevNIYyg==
-----END PUBLIC KEY-----</textarea>
<pre><code class="js-hex"> </code></pre>
<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 convert() {
console.log('keyup');
var json;
try {
var pem = PEM.parseBlock(document.querySelector('.js-input').value);
var hex = Enc.bufToHex(pem.der);
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);
}
$input.addEventListener('keyup', convert);
convert();
</script>
</body>
</html>