2018-12-02 05:13:03 +00:00
<!DOCTYPE html>
< html >
< head >
< title > SSH Pub Parser - Bluecrypt< / title >
< style >
textarea {
width: 42em;
height: 10em;
}
< / style >
< / head >
< body >
< h1 > Bluecrypt SSH Public Key Parser< / h1 >
< textarea class = "js-input" placeholder = "Paste id_rsa.pub (or other SSH public key) here" > ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCba21UHE+VbDTpmYYFZUOV+OQ8AngOCdjROsPC0KiEfMvEaEM3NQl58u6QL7G7QsErKViiNPm9OTFo6HF5JijfWzK7haHFuRMEsgI4VwIYyhvqlJDfw/wt0AiVvSmoMfEQn1p1aiaO4V/RJSE3Vw/uz2bxiT22uSkSqOyShyfYE6dMHnuoBkzr4jvSifT+INmbv6Nyo4+AAMCZtYeHLrsFeSTjLL9jMPjI4ZkVdlw2n3Xn9NbltF3/8Ao8dQfElqw+LIQWqU0oFHYNIP4ttfl5ObMKHaKSvBMyNruZR0El/ZsrcHLkAHRCLj07KRQJ81l5CUTPtQ02P1Eamz/nT4I3 root@localhost< / textarea >
< pre > < code class = "js-hex" > < / code > < / pre >
< pre > < code class = "js-jwk" > < / code > < / pre >
< br >
2018-12-04 00:14:51 +00:00
< p > Made with < a href = "https://git.coolaj86.com/coolaj86/bluecrypt-ssh-to-jwk.js/" > ssh-to-jwk.js< / a > (Browser friendly)< / p >
< p > Also available for node.js: < a href = "https://git.coolaj86.com/coolaj86/ssh-to-jwk.js/" > ssh-to-jwk.js< / a > < / p >
2018-12-02 05:13:03 +00:00
< script src = "./ssh-to-jwk.js" > < / script >
< script >
'use strict';
Enc.bufToHex = function toHex(u8) {
var hex = [];
var i, h;
var len = (u8.byteLength || u8.length);
for (i = 0; i < len ; i + = 1 ) {
h = u8[i].toString(16);
if (h.length % 2) { h = '0' + h; }
hex.push(h);
}
return hex.join('').toLowerCase();
};
var $input = document.querySelector('.js-input');
function convert() {
console.log('keyup');
var ssh;
try {
var text = document.querySelector('.js-input').value.trim();
ssh = SSH.parse(text);
document.querySelector('.js-hex').innerText = ssh.elements.map(function (hex) {
return Enc.bufToHex(hex)
.match(/.{2}/g).join(' ')
.match(/.{1,24}/g).join(' ')
.match(/.{1,50}/g).join('\n');
}).join('\n\n')
document.querySelector('.js-jwk').innerText = JSON.stringify(ssh.jwk, null, 2);
} catch(e) {
ssh = { error: { message: e.message } };
document.querySelector('.js-hex').innerText = '';
document.querySelector('.js-jwk').innerText = JSON.stringify(ssh, null, 2);
}
}
$input.addEventListener('keyup', convert);
convert();
< / script >
< / body >
< / html >