Skip to content

Commit

Permalink
{En,De}codeHex: add documentation about the encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
dolmen committed Jun 26, 2018
1 parent 82b8d76 commit b97bdbf
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hashids.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ func (h *HashID) EncodeInt64(numbers []int64) (string, error) {
// EncodeHex hashes a hexadecimal string to a string containing at least MinLength characters taken from the Alphabet.
// A hexadecimal string should not contain the 0x prefix.
// Use DecodeHex using the same Alphabet and Salt to get back the hexadecimal string.
//
// Each hex nibble is encoded as an integer in range [16, 31].
func (h *HashID) EncodeHex(hex string) (string, error) {
nums := make([]int, len(hex))

Expand Down Expand Up @@ -329,6 +331,8 @@ func (h *HashID) DecodeInt64WithError(hash string) ([]int64, error) {

// DecodeHex unhashes the string passed to a hexadecimal string.
// It is symmetric with EncodeHex if the Alphabet and Salt are the same ones which were used to hash.
//
// Each hex nibble is decoded from an integer in range [16, 31].
func (h *HashID) DecodeHex(hash string) (string, error) {
numbers, err := h.DecodeInt64WithError(hash)
if err != nil {
Expand Down

0 comments on commit b97bdbf

Please sign in to comment.