-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ca293f4
Showing
8 changed files
with
765 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
### Go ### | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
### Go Patch ### | ||
/vendor/ | ||
/Godeps/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM golang:1.15 as builder | ||
|
||
RUN mkdir /opt/app/ | ||
WORKDIR /opt/app/ | ||
|
||
ENV GOOS=js | ||
ENV GOARCH=wasm | ||
|
||
ADD golang/ssh-keygen.go /opt/app/ | ||
RUN go get golang.org/x/crypto/ssh | ||
RUN go build -o ssh-keygen.wasm ssh-keygen.go | ||
|
||
FROM nginx | ||
|
||
RUN sed -i -e "5a application/wasm wasm;" /etc/nginx/mime.types | ||
|
||
COPY --from=builder /opt/app/ssh-keygen.wasm /usr/share/nginx/html/ | ||
ADD docs/* /usr/share/nginx/html/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# WASM ssh-keygen example | ||
|
||
これはWASMを利用して、ブラウザ上でSSH鍵ペアを生成するサンプルです。 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
export GOOS=js | ||
export GOARCH=wasm | ||
|
||
mkdir -p dist/ | ||
cd golang/ | ||
go get "golang.org/x/crypto/ssh" | ||
go build -o ../docs/ssh-keygen.wasm ssh-keygen.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<!doctype html> | ||
<!-- | ||
Copyright 2018 The Go Authors. All rights reserved. | ||
Use of this source code is governed by a BSD-style | ||
license that can be found in the LICENSE file. | ||
--> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>Go wasm</title> | ||
</head> | ||
|
||
<body> | ||
<!-- | ||
Add the following polyfill for Microsoft Edge 17/18 support: | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/encoding.min.js"></script> | ||
(see https://caniuse.com/#feat=textencoder) | ||
--> | ||
<script src="wasm_exec.js"></script> | ||
<script> | ||
if (!WebAssembly.instantiateStreaming) { // polyfill | ||
WebAssembly.instantiateStreaming = async (resp, importObject) => { | ||
const source = await (await resp).arrayBuffer(); | ||
return await WebAssembly.instantiate(source, importObject); | ||
}; | ||
} | ||
|
||
const go = new Go(); | ||
let mod, inst; | ||
WebAssembly.instantiateStreaming(fetch("ssh-keygen.wasm"), go.importObject).then((result) => { | ||
mod = result.module; | ||
inst = result.instance; | ||
go.run(result.instance); | ||
document.getElementById("runButton").disabled = false; | ||
}).catch((err) => { | ||
console.error(err); | ||
}); | ||
|
||
async function run() { | ||
keypair = sshKeyGen.GenerateRSAKeyPair(); | ||
console.log(keypair); | ||
|
||
document.getElementById("publicKey").value = keypair.publicKey; | ||
document.getElementById("privateKey").value = keypair.privateKey; | ||
} | ||
</script> | ||
|
||
<button onClick="run();" id="runButton" disabled>Run</button> | ||
|
||
<h3>PublicKey</h3> | ||
<textarea id="publicKey"></textarea> | ||
<h3>PrivateKey</h3> | ||
<textarea id="privateKey"></textarea> | ||
|
||
</body> | ||
|
||
</html> |
Binary file not shown.
Oops, something went wrong.