Skip to content

Added new Example in readme for setting alphabet to be used instead of DefaultAlphabet #47

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,27 @@ func main() {
}
```

If you wish to set your own Alhabets in the HashId rather than using the default ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"), you can use this example. You can replace the hd.Alphabet string with the alphabets that you might want to see in your hash id. Please note: Minimum Alphabet length should be 16 with unique characters.
```go
package main

import "fmt"
import "github.com/speps/go-hashids"

func main() {
hd := hashids.NewData()
hd.Salt = "this is my salt"
hd.MinLength = 30
hd.Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
h, _ := hashids.NewWithData(hd)
e, _ := h.Encode([]int{45, 434, 1313, 99})
fmt.Println(e)
d, _ := h.DecodeWithError(e)
fmt.Println(d)
}
```


### Thanks to all the contributors

* [Harm Aarts](https://github.com/haarts)
Expand Down