Skip to content

Commit

Permalink
Implement suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
PineappleIOnic committed Jun 26, 2022
1 parent f6e1369 commit dfb7224
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ use ext_php_rs::prelude::*;
pub fn scrypt(
password: &str,
salt: Binary<u8>,
cpu_difficulty: Option<u32>,
cpu_difficulty: Option<f64>,
memory_difficulty: Option<u32>,
parallel_difficulty: Option<u32>,
len: Option<usize>,
) -> Result<String, String> {
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);
Expand Down

0 comments on commit dfb7224

Please sign in to comment.