js-keygen/index.html
Patrick Roumanoff aa49d05c58 working state
2015-09-03 21:58:00 +10:00

72 lines
No EOL
2.6 KiB
HTML

<!doctype html>
<html>
<head>
<title>Key Pair generation for SSH access</title>
<script src="base64url.js"></script>
<script src="ssh-util.js"></script>
<script src="keypair.js"></script>
<style>
label {
display: inline-block;
width: 80px;
}
select{
width: 200px;
}
input {
width: 180px;
}
</style>
</head>
<body>
<div><label for="name">Name:</label><input id="name" type="text" value="me@domain"></div>
<div><label for="alg">Algorithm:</label><select id="alg"><option value="RSASSA-PKCS1-v1_5" selected>RSASSA-PKCS1-v1_5</option></select>
<label for="size">Size:</label><input id="size" type="text" value="2048"></div>
<div><label for="hash">Hash:</label><select id="hash">
<option value="SHA-1">SHA-1</option>
<option value="SHA-256">SHA-256</option>
<option value="SHA-384">SHA-384</option>
<option value="SHA-512">SHA-512</option>
</select></div>
<button id="generate">Generate</button>
<br>
<hr>
<a id="private" style="display: none;" href="" download="id_rsa">id_rsa</a>
<a id="public" style="display: none;" href="" download="id_rsa.pub">id_rsa.pub</a>
Private Key <button id="copyPrivate">Copy</button> or <button id="savePrivate">Save</button><br>
<textarea id="privateKey" style="overflow: scroll; width: 650px; height: 150px; word-wrap:break-word;font-family: monospace;" spellcheck="false"></textarea>
<hr>
Public Key <button id="copyPublic">Copy</button> or <button id="savePublic">Save</button><br>
<textarea id="publicKey" style="width: 650px; height: 70px; word-wrap:break-word;font-family: monospace;" spellcheck="false"></textarea>
<script>
function copy(id) {
return function() {
var ta = document.querySelector(id);
ta.focus();
ta.select();
try {
var successful = document.execCommand('copy');
var msg = successful ? 'successful' : 'unsuccessful';
console.log('Copy key command was ' + msg);
} catch(err) {
console.log('Oops, unable to copy');
}
window.getSelection().removeAllRanges();
ta.blur();
}
}
document.querySelector('#savePrivate').addEventListener('click', function(event) {
document.querySelector('a#private').click();
});
document.querySelector('#copyPrivate').addEventListener('click', copy('#privateKey'));
document.querySelector('#savePublic').addEventListener('click', function(event) {
document.querySelector('a#public').click();
});
document.querySelector('#copyPublic').addEventListener('click', copy('#publicKey'));
</script>
</body>
</html>