-
Notifications
You must be signed in to change notification settings - Fork 6
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
1 parent
1f2a5c9
commit 7233f02
Showing
10 changed files
with
681 additions
and
2 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
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
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,32 @@ | ||
//go:build wasm | ||
// +build wasm | ||
|
||
package main | ||
|
||
import ( | ||
"syscall/js" | ||
|
||
"github.com/supercaracal/scram-sha-256/pkg/pgpasswd" | ||
) | ||
|
||
func handleButton(this js.Value, inputs []js.Value) interface{} { | ||
document := js.Global().Get("document") | ||
input := document.Call("getElementById", "raw-password") | ||
result := document.Call("getElementById", "encrypted-password") | ||
|
||
rawPassword := input.Get("value").String() | ||
|
||
if encrypted, err := pgpasswd.Encrypt([]byte(rawPassword)); err != nil { | ||
result.Set("value", err.Error()) | ||
} else { | ||
result.Set("value", encrypted) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func main() { | ||
button := js.Global().Get("document").Call("getElementById", "encryption-button") | ||
button.Call("addEventListener", "click", js.FuncOf(handleButton)) | ||
select {} | ||
} |
Binary file not shown.
Binary file not shown.
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,23 @@ | ||
<!DOCTYPE html> | ||
<html lang="ja"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> | ||
<title>scram-sha-256</title> | ||
<link rel="shortcut icon" type="image/x-icon" href="/scram-sha-256/favicon.ico" /> | ||
<link rel="stylesheet" media="all" href="/scram-sha-256/style.css" /> | ||
<script src="/scram-sha-256/wasm_exec.js"></script> | ||
<script src="/scram-sha-256/script.js"></script> | ||
</head> | ||
<body> | ||
<div class="block"> | ||
<input type="password" value="" id="raw-password" /> | ||
<input type="button" value="encrypt" id="encryption-button" /> | ||
</div> | ||
<div class="block"> | ||
<input id="encrypted-password" value="" readonly /> | ||
</div> | ||
<div class="block"> | ||
<span><a href="https://github.com/supercaracal/scram-sha-256">GitHub</a></span> | ||
</div> | ||
</body> |
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 @@ | ||
"use strict"; | ||
|
||
window.addEventListener('load', (event) => { | ||
const go = new Go(); | ||
|
||
WebAssembly | ||
.instantiateStreaming(fetch('/scram-sha-256/encrypt.wasm'), go.importObject) | ||
.then((result) => go.run(result.instance)); | ||
}); |
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,36 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
) | ||
|
||
const ( | ||
appName = "scram-sha-256" | ||
) | ||
|
||
var ( | ||
staticFiles = []string{ | ||
"encrypt.wasm", | ||
"favicon.ico", | ||
"script.js", | ||
"style.css", | ||
"wasm_exec.js", | ||
} | ||
) | ||
|
||
func makeStaticHandler(f string) func(http.ResponseWriter, *http.Request) { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
http.ServeFile(w, r, f) | ||
} | ||
} | ||
|
||
func main() { | ||
http.HandleFunc("/", makeStaticHandler("index.html")) | ||
|
||
for _, f := range staticFiles { | ||
http.HandleFunc(fmt.Sprintf("/%s/%s", appName, f), makeStaticHandler(f)) | ||
} | ||
|
||
http.ListenAndServe(":3000", nil) | ||
} |
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,15 @@ | ||
body { | ||
background-color: #555555; | ||
} | ||
|
||
div.block { | ||
margin-top: 10px; | ||
} | ||
|
||
input#raw-password { | ||
width: 480px; | ||
} | ||
|
||
input#encrypted-password { | ||
width: 1280px; | ||
} |
Oops, something went wrong.