Skip to content

Commit

Permalink
Update README.md and add deprecation to methods that panic.
Browse files Browse the repository at this point in the history
  • Loading branch information
speps committed Feb 20, 2016
1 parent 9aaed95 commit d1d57a8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
33 changes: 23 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,36 @@ func main() {
h := hashids.NewWithData(hd)
e, _ := h.Encode([]int{45, 434, 1313, 99})
fmt.Println(e)
d := h.Decode(e)
d, _ := h.DecodeWithError(e)
fmt.Println(d)
}
```

### Test results

```
=== RUN TestEncryptDecrypt
--- PASS: TestEncryptDecrypt (0.00 seconds)
hashids_test.go:21: [45 434 1313 99] -> woQ2vqjnG7nnhzEsDkiYadKa3O71br -> [45 434 1313 99]
=== RUN TestDefaultLength
--- PASS: TestDefaultLength (0.00 seconds)
hashids_test.go:47: [45 434 1313 99] -> 7nnhzEsDkiYa -> [45 434 1313 99]
=== RUN TestCustomAlphabet
--- PASS: TestCustomAlphabet (0.00 seconds)
hashids_test.go:74: [45 434 1313 99] -> MAkhkloFAxAoskax -> [45 434 1313 99]
=== RUN TestEncryptDecrypt
--- PASS: TestEncryptDecrypt (0.00s)
hashids_test.go:22: [45 434 1313 99] -> woQ2vqjnG7nnhzEsDkiYadKa3O71br -> [45 434 1313 99]
=== RUN TestEncryptDecryptInt64
--- PASS: TestEncryptDecryptInt64 (0.00s)
hashids_test.go:49: [45 434 1313 99 9223372036854775807] -> ZvGlaahBptQNfPOuPjJ51zO3wVzP01 -> [45 434 1313 99 9223372036854775807]
=== RUN TestEncryptWithKnownHash
--- PASS: TestEncryptWithKnownHash (0.00s)
hashids_test.go:75: [45 434 1313 99] -> 7nnhzEsDkiYa
=== RUN TestDecryptWithKnownHash
--- PASS: TestDecryptWithKnownHash (0.00s)
hashids_test.go:92: 7nnhzEsDkiYa -> [45 434 1313 99]
=== RUN TestDefaultLength
--- PASS: TestDefaultLength (0.00s)
hashids_test.go:115: [45 434 1313 99] -> 7nnhzEsDkiYa -> [45 434 1313 99]
=== RUN TestMinLength
--- PASS: TestMinLength (0.00s)
=== RUN TestCustomAlphabet
--- PASS: TestCustomAlphabet (0.00s)
hashids_test.go:150: [45 434 1313 99] -> MAkhkloFAxAoskax -> [45 434 1313 99]
=== RUN TestDecryptWithError
--- PASS: TestDecryptWithError (0.00s)
PASS
```

Expand Down
2 changes: 2 additions & 0 deletions hashids.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ func (h *HashID) EncodeInt64(numbers []int64) (string, error) {
return string(result), nil
}

// DEPRECATED: Use DecryptWithError instead
// Decode unhashes the string passed to an array of int.
// It is symmetric with Encode if the Alphabet and Salt are the same ones which were used to hash.
// MinLength has no effect on Decode.
Expand All @@ -223,6 +224,7 @@ func (h *HashID) DecodeWithError(hash string) ([]int, error) {
return result, nil
}

// DEPRECATED: Use DecryptInt64WithError instead
// DecodeInt64 unhashes the string passed to an array of int64.
// It is symmetric with EncodeInt64 if the Alphabet and Salt are the same ones which were used to hash.
// MinLength has no effect on DecodeInt64.
Expand Down

0 comments on commit d1d57a8

Please sign in to comment.