From f3de9b4eb42231aa43350ddaad5dd01045677f50 Mon Sep 17 00:00:00 2001 From: Arzumify Date: Sat, 20 Jul 2024 16:48:14 +0100 Subject: [PATCH] Added the code --- .gitignore | 1 + build.sh | 1 + go.mod | 5 +++++ go.sum | 2 ++ main.go | 26 ++++++++++++++++++++++++++ 5 files changed, 35 insertions(+) create mode 100644 .gitignore create mode 100755 build.sh create mode 100644 go.mod create mode 100644 go.sum create mode 100644 main.go diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..c764de1 --- /dev/null +++ b/build.sh @@ -0,0 +1 @@ +GOOS=js GOARCH=wasm go build -o hashcat.wasm diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..7c7c390 --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module concord.hectabit.org/Hectabit/hashcat-wasm + +go 1.22.5 + +require github.com/catalinc/hashcash v1.0.0 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..5403402 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/catalinc/hashcash v1.0.0 h1:DiI2kBNCczy7y3xJnLddIl7KGx0yP4B7irFZZ+yzzwc= +github.com/catalinc/hashcash v1.0.0/go.mod h1:ldWL6buwYCK4VqIkLbZuFbGUoJceSafm8duCEQYw9Jw= diff --git a/main.go b/main.go new file mode 100644 index 0000000..4ba89f5 --- /dev/null +++ b/main.go @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "github.com/catalinc/hashcash" + "syscall/js" +) + +func main() { + fmt.Println("HashCash online! (no, curious console-dweller, this isn't a cryptocurrency miner)") + fmt.Println("Beginning proof of work (this may take a while)...") + pow := hashcash.New(20, 16, "I love burgernotes!") + stamp, err := pow.Mint("signup") + if err != nil { + js.Global().Set("returnVar", js.ValueOf(err.Error())) + js.Global().Set("returnCode", js.ValueOf(2)) + fmt.Println("An error occurred whilst working:", err) + js.Global().Call("WASMComplete") + } else { + js.Global().Set("returnVar", js.ValueOf(stamp)) + js.Global().Set("returnCode", js.ValueOf(0)) + fmt.Println("Proof of work completed successfully:", stamp) + fmt.Println("Again, no, this isn't a Crypto miner. It's an anti-spam measure. I promise.") + js.Global().Call("WASMComplete") + } +}