diff --git a/Cargo.toml b/Cargo.toml index 4b8d8fd..b9b9f27 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "scrypt-php" -version = "0.1.0" +version = "0.0.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/README.md b/README.md index 8ee704d..dee1a7a 100644 --- a/README.md +++ b/README.md @@ -22,11 +22,10 @@ $hash = \scrypt("password", "salt", 32768, 8, 1, 64); ## Building the extension Building this extension requires that you have a version of PHP installed that has the `php-config` command. -After all the prequisites are met simply run +After all the prequisites are met simply run the following command to build a release version of the extension: ```sh cargo build --release ``` -to build a release version of the extension ### Building for Alpine While writing this extension we found out that [Rust in general](https://github.com/rust-lang/rust/issues/59302) still has a few issues with [musl libc](https://musl.libc.org/) found in Alpine. It is possible to build this project successfully by using an alternative linker and building on a gnu-based system targetting linux-unknown-musl. @@ -49,6 +48,9 @@ This will produce a .so file similar to a normal build. - [https://github.com/meldiron](https://github.com/meldiron) +**Eldad Fux** +- [https://github.com/eldadfux](https://github.com/eldadfux) + ## Copyright and license The MIT License (MIT) [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php) diff --git a/src/lib.rs b/src/lib.rs index a5255db..b904f5a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,7 +15,7 @@ use ext_php_rs::prelude::*; pub fn scrypt( password: &str, salt: Binary, - cpu_difficulty: Option, + cpu_difficulty: Option, memory_difficulty: Option, parallel_difficulty: Option, len: Option, @@ -23,7 +23,7 @@ pub fn scrypt( let password = password.as_bytes(); let n = match cpu_difficulty { - Some(data) => fast_math::log2(data as f32) as u8, + Some(data) => data.log2() as u8, None => 15, // 32768 }; let r = memory_difficulty.unwrap_or(8);