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 compatability? #25

Closed
xacrimon opened this issue Jan 5, 2020 · 5 comments
Closed

wasm compatability? #25

xacrimon opened this issue Jan 5, 2020 · 5 comments

Comments

@xacrimon
Copy link

xacrimon commented Jan 5, 2020

Currently this crate is not wasm compatible due to use of threads. Would it be possible to add wasm compatability?

@zer0x64
Copy link

zer0x64 commented Feb 24, 2020

On my setup, it works if you disable the default features! Simply add this to your Cargo.toml:

rust-argon2 = { version = "0.8.1", default-features = false }

@praveenperera
Copy link

@zer0x64

That makes sense looks like disable default-features makes it run Sequential Thread Mode

https://github.com/sru-systems/rust-argon2/blob/master/src/argon2.rs#L306

#[cfg_attr(feature = "crossbeam-utils", doc = "config.lanes = 4;")]
#[cfg_attr(
    feature = "crossbeam-utils",
    doc = "config.thread_mode = ThreadMode::Parallel;"
)]
#[cfg_attr(not(feature = "crossbeam-utils"), doc = "config.lanes = 1;")]
#[cfg_attr(
    not(feature = "crossbeam-utils"),
    doc = "config.thread_mode = ThreadMode::Sequential;"
)]

https://docs.sru-systems.com/rust-argon2/0.8.0/argon2/enum.ThreadMode.html

@zer0x64
Copy link

zer0x64 commented Feb 24, 2020

And this should also the intended behavior for WASM, since multithreading is not supported at the moment(although there are some POC using webworkers and shared-memory, but that requires manual setup on the browser to run)

@zer0x64
Copy link

zer0x64 commented Feb 24, 2020

One improvement would be to disable the feature when building for wasm32 at the crate level, but this ability juste made it to nightly, so it might take some time until it makes it into stable:
rust-lang/cargo#7914

@mrijkeboer
Copy link
Member

Hi @xacrimon, as @zer0x64 suggested you can accomplish this by turning the default features off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants