Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WASM conversion for Argon2 hashing #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions argon2.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added argon2.wasm
Binary file not shown.
31 changes: 31 additions & 0 deletions compile-wasm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# Clone and set up Emscripten SDK
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
cd ..

# Clone the Argon2 repository
git clone https://github.com/P-H-C/phc-winner-argon2.git
cd phc-winner-argon2

# Compile Argon2 to WebAssembly
emcc -Iinclude -O3 -s WASM=1 -s MODULARIZE=1 \
-s 'EXTRA_EXPORTED_RUNTIME_METHODS=["cwrap", "UTF8ToString"]' \
-s 'EXPORTED_FUNCTIONS=["_argon2_hash", "_argon2_error_message", "_malloc", "_free"]' \
-o argon2.js src/argon2.c src/core.c src/blake2/blake2b.c src/thread.c src/encoding.c src/ref.c

# Move the generated files to the parent directory
mv argon2.js ../
mv argon2.wasm ../

# Go back to the parent directory
cd ..

# Clean up
rm -rf emsdk phc-winner-argon2

echo "WASM files compiled and moved to the project root successfully."
11 changes: 11 additions & 0 deletions download-wasm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# URLs for the WASM files
ARGON2_JS_URL="https://raw.githubusercontent.com/antelle/argon2-browser/master/docs/dist/argon2.js"
ARGON2_WASM_URL="https://raw.githubusercontent.com/antelle/argon2-browser/master/docs/dist/argon2.wasm"

# Download the files
curl -o argon2.js $ARGON2_JS_URL
curl -o argon2.wasm $ARGON2_WASM_URL

echo "WASM files downloaded successfully."
Loading