GithubHelp home page GithubHelp logo

WASM/no_std support about password-hashes HOT 4 CLOSED

rustcrypto avatar rustcrypto commented on August 25, 2024
WASM/no_std support

from password-hashes.

Comments (4)

newpavlov avatar newpavlov commented on August 25, 2024 1

We have released scrypt v0.3 with no_std support, also we now test that all crates can be built on WASM. So I think we can close this issue.

from password-hashes.

newpavlov avatar newpavlov commented on August 25, 2024

scrypt depends on std, which causes issues in your case. It can be solved by migrating it to alloc, which will require bumping MSRV and thus releasing v0.3.0.

from password-hashes.

slightknack avatar slightknack commented on August 25, 2024

I'm not sure if this is just a simple misconfig-uration on my part, but I'm not able to get scrypt running on wasm32-unknown-unknown. According to this issue for the rand crate, the "wasm-bindgen" feature should be flagged for WASM compilation.

However, from past experience, rand hasn't been the most reliable for WASM for me. The getrandom crate supports WASM reliably; I wonder if it might be a good idea to switch to it. Here's my code:

# Cargo.toml

# ... snip ...

scrypt = "0.3"
// lib.rs
extern crate scrypt;
use scrypt::{ScryptParams, scrypt_check, scrypt_simple};

// ... snip ...

// in some function:
let params = ScryptParams::new(15, 8, 1).unwrap();
let password = "some password";
let hash = scrypt_simple(password, &params).expect("Rng failed");

Compiled with:

$ cargo build --lib --release --target wasm32-unknown-unknown

When run, the script reports that the Rng failed. I'm not exactly sure where this error occurs - I think it might be while filling the salt with random values in scrypt_simple. I'm going to try rewriting my own scrypt_simple that doesn't depend on the same Rng and see if an error is still thrown.

from password-hashes.

newpavlov avatar newpavlov commented on August 25, 2024

Have you tried to add this line to your Cargo.toml?

getrandom = { version = "0.1", features = ["wasm-bindgen"] }

AFAIK rand does not have any WASM-incompatible parts, so issue is usually that the getrandom feature does not get enabled.

from password-hashes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.