diff --git a/README.md b/README.md
index 437ec74..77b283d 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,4 @@
-Generate a ssh keypair using the webcrypto API
-==
+# Generate a ssh keypair using the webcrypto API
See the live demo at https://js-keygen.surge.sh
@@ -11,8 +10,6 @@ There is no way to generate a ssh keypair on the chrome book, but we have access
* I had to learn about ASN.1 to encode the private key for OpenSSH
* I had to lean about the open SSH public format to encode the public key for OpenSSH
-
The end result is a usable single page app that will locally generate a keypair you can save to local drive. Allowing you to do that straight from chrome on a chrome book.
Everywhere else, you should have access to ssh-keygen which is the recommended way to generate keypair for SSH.
-
diff --git a/base64url.js b/base64url.js
index 8a35147..816968c 100644
--- a/base64url.js
+++ b/base64url.js
@@ -3,26 +3,26 @@
function base64urlEncode(arg) {
var s = window.btoa(arg); // Regular base64 encoder
- s = s.split('=')[0]; // Remove any trailing '='s
- s = s.replace(/\+/g, '-'); // 62nd char of encoding
- s = s.replace(/\//g, '_'); // 63rd char of encoding
+ s = s.split("=")[0]; // Remove any trailing '='s
+ s = s.replace(/\+/g, "-"); // 62nd char of encoding
+ s = s.replace(/\//g, "_"); // 63rd char of encoding
return s;
}
function base64urlDecode(s) {
- s = s.replace(/-/g, '+'); // 62nd char of encoding
- s = s.replace(/_/g, '/'); // 63rd char of encoding
+ s = s.replace(/-/g, "+"); // 62nd char of encoding
+ s = s.replace(/_/g, "/"); // 63rd char of encoding
switch (s.length % 4) { // Pad with trailing '='s
- case 0: // No pad chars in this case
- break;
- case 2: // Two pad chars
- s += "==";
- break;
- case 3: // One pad char
- s += "=";
- break;
- default:
- throw "Illegal base64url string!";
+ case 0: // No pad chars in this case
+ break;
+ case 2: // Two pad chars
+ s += "==";
+ break;
+ case 3: // One pad char
+ s += "=";
+ break;
+ default:
+ throw "Illegal base64url string!";
}
return window.atob(s); // Standard base64 decoder
}
diff --git a/index.html b/index.html
index 54dedda..a1e492a 100644
--- a/index.html
+++ b/index.html
@@ -1,59 +1,86 @@
+
js-keygen
-
-
+
+
+
-
js-keygen
-
- Generate a keypair to be used with openSSH, this replicate ssh-keygen function in javascript in the browser, using the webcrypto api and a bit of glue.
- For an in-depth explanation on how this work, see the blog post.
- Usually you would want to save the private key to the machine initiating the ssh connection, and you want to copy the public key to the system receiving the connection.
- No data is being sent to the server, everything happens within the context of this web page.
- Tweet
-
-
-
+ Generate a keypair to be used with openSSH, this replicate ssh-keygen function in javascript in the browser, using the webcrypto
+ api and a bit of glue.
+ For an in-depth explanation on how this work, see the
+ blog post.
+ Usually you would want to save the private key to the machine initiating the ssh connection, and you want to copy the
+ public key to the system receiving the connection.
+ No data is being sent to the server, everything happens within the context of this web page.
+
+ Tweet
+
- Public Key or
-
-