SSH Fingerprint in < 150 lines of VanillaJS, part of the Bluecrypt suite for Browser Crypto.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

67 lines
2.4 KiB

<!DOCTYPE html>
<html>
<head>
<title>SSH Fingerprint Generator - Bluecrypt</title>
<style>
textarea {
width: 42em;
height: 10em;
}
pre {
white-space: pre-wrap;
}
.code {
width: 31em;
word-wrap: break-word;
}
</style>
</head>
<body>
<h1>Bluecrypt SSH Fingerprint Generator</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-fingerprint"> </code></pre>
<div class="code">
<pre><code class="js-json"> </code></pre>
</div>
<br>
<p>Made with <a href="https://git.coolaj86.com/coolaj86/bluecrypt-ssh-fingerprint.js/">ssh-fingerprint.js</a> (Browser friendly)</p>
<p>Also available for node.js &amp; CLI: <a href="https://git.coolaj86.com/coolaj86/ssh-fingerprint.js/">ssh-fingerprint.js</a></p>
<script src="./ssh-fingerprint.js"></script>
<script>
'use strict';
var $input = document.querySelector('.js-input');
function convert() {
console.log('keyup');
try {
var pub = document.querySelector('.js-input').value.trim();
SSH.fingerprint({ pub: pub }).then(function (fing) {
var arr = [];
console.log(fing);
document.querySelector('.js-fingerprint').innerText = 'The key fingerprint is:\n'
+ fing.fingerprint + ' ' + fing.comment;
fing.digest.forEach(function (i) { arr.push(i); });
fing.digest = 'Uint8Array <' + arr.join() + '>';
document.querySelector('.js-json').innerText = JSON.stringify(fing, null, 1);
}).catch(function (e) {
var msg = { error: { message: e.message } };
document.querySelector('.js-fingerprint').innerText = JSON.stringify(msg, null, 2);
});
} catch(e) {
var msg = { error: { message: e.message } };
document.querySelector('.js-fingerprint').innerText = JSON.stringify(msg, null, 2);
}
}
$input.addEventListener('keyup', convert);
convert();
</script>
</body>
</html>