updated readme to match latest api
This commit is contained in:
parent
769bf21c61
commit
ffe66b007d
3 changed files with 50 additions and 43 deletions
76
README.md
76
README.md
|
@ -35,57 +35,61 @@ argon2-creds = { version = "0.1", git = "https://github.com/realaravinth/argon2-
|
||||||
implementation for the default configuration.
|
implementation for the default configuration.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use argon2_creds::Config;
|
use argon2_creds::Config;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let config = Config::default();
|
let config = Config::default();
|
||||||
|
|
||||||
let password = "ironmansucks";
|
let password = "ironmansucks";
|
||||||
let hash = config.password(password).unwrap();
|
|
||||||
|
|
||||||
// email validation
|
// email validation
|
||||||
config.email(Some("batman@we.net")).unwrap();
|
config.email(Some("batman@we.net")).unwrap();
|
||||||
|
|
||||||
// process username
|
// process username
|
||||||
let username = config.username("Realaravinth").unwrap(); // process username
|
let username = config.username("Realaravinth").unwrap(); // process username
|
||||||
|
|
||||||
// generate hash
|
// generate hash
|
||||||
let hash = config.password(password).unwrap();
|
let hash = config.password(password).unwrap();
|
||||||
|
|
||||||
assert_eq!(username, "realaravinth");
|
assert_eq!(username, "realaravinth");
|
||||||
assert!(Config::verify(&hash, password).unwrap(), "verify hahsing");
|
assert!(Config::verify(&hash, password).unwrap(), "verify hahsing");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
2. To gain fine-grained control over how credentials are managed, consider using
|
2. To gain fine-grained control over how credentials are managed, consider using
|
||||||
[ConfigBuilder]:
|
[ConfigBuilder]:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use argon2_creds::{ConfigBuilder, Config};
|
use argon2_creds::{Config, ConfigBuilder, PasswordPolicyBuilder};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let config = ConfigBuilder::default()
|
let config = ConfigBuilder::default()
|
||||||
.salt_length(32)
|
.username_case_mapped(false)
|
||||||
.username_case_mapped(false)
|
.profanity(true)
|
||||||
.profanity(true)
|
.blacklist(false)
|
||||||
.blacklist(false)
|
.password_policy(
|
||||||
.argon2(argon2::Config::default())
|
PasswordPolicyBuilder::default()
|
||||||
.build()
|
.min(12)
|
||||||
.unwrap();
|
.max(80)
|
||||||
|
.build()
|
||||||
|
.unwrap(),
|
||||||
|
)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let password = "ironmansucks";
|
let password = "ironmansucks";
|
||||||
let hash = config.password(password).unwrap();
|
let hash = config.password(password).unwrap();
|
||||||
|
|
||||||
// email validation
|
// email validation
|
||||||
config.email(Some("batman@we.net")).unwrap();
|
config.email(Some("batman@we.net")).unwrap();
|
||||||
|
|
||||||
// process username
|
// process username
|
||||||
let username = config.username("Realaravinth").unwrap(); // process username
|
let username = config.username("Realaravinth").unwrap(); // process username
|
||||||
|
|
||||||
// generate hash
|
// generate hash
|
||||||
let hash = config.password(password).unwrap();
|
let hash = config.password(password).unwrap();
|
||||||
|
|
||||||
assert_eq!(username, "realaravinth");
|
assert_eq!(username, "realaravinth");
|
||||||
assert!(Config::verify(&hash, password).unwrap(), "verify hahsing");
|
assert!(Config::verify(&hash, password).unwrap(), "verify hahsing");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
//To gain fine-grained control over how credentials are managed, consider using ConfigBuilder:
|
/* To gain fine-grained control over how credentials are managed,
|
||||||
|
* consider using ConfigBuilder:
|
||||||
|
*/
|
||||||
|
|
||||||
use argon2_creds::{Config, ConfigBuilder, PasswordPolicyBuilder};
|
use argon2_creds::{Config, ConfigBuilder, PasswordPolicyBuilder};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
// The easiest way to use this crate is with the default configuration. See `Default`
|
/* The easiest way to use this crate is with the default configuration.
|
||||||
// implementation for the default configuration.
|
* See `Default` implementation for the default configuration.
|
||||||
|
*/
|
||||||
|
|
||||||
use argon2_creds::Config;
|
use argon2_creds::Config;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue