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

Add opportunity to use unwrap and change 2 spaces indent to 4 spaces #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,20 @@ let numbers_5: Vec<i64> = vec![5];
let encode_5 = ids.encode(&numbers_5);
```

### Simple usage
```rust
extern crate hashids;
use hashids::HashIds;

fn main() {
let ids = HashIds::new_with_salt("this is my salt".to_string()).unwrap();
let numbers: Vec<i64> = vec!(21312321, 34);
let encode = ids.encode(&numbers);

println!("{}", encode);
}
```

## Bad hashes

I wrote this class with the intent of placing these hashes in visible places - like the URL. If I create a unique hash for each user, it would be unfortunate if the hash ended up accidentally being a bad word. Imagine auto-creating a URL with hash for your user that looks like this - `http://example.com/user/a**hole`
Expand Down
10 changes: 10 additions & 0 deletions examples/simple.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
extern crate hashids;
use hashids::HashIds;

fn main() {
let ids = HashIds::new_with_salt("this is my salt".to_string()).unwrap();
let numbers: Vec<i64> = vec!(21312321, 34);
let encode = ids.encode(&numbers);

println!("{}", encode);
}
Loading