Skip to content

Commit b97bdbf

Browse files
committed
{En,De}codeHex: add documentation about the encoding
1 parent 82b8d76 commit b97bdbf

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

hashids.go

+4
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ func (h *HashID) EncodeInt64(numbers []int64) (string, error) {
223223
// EncodeHex hashes a hexadecimal string to a string containing at least MinLength characters taken from the Alphabet.
224224
// A hexadecimal string should not contain the 0x prefix.
225225
// Use DecodeHex using the same Alphabet and Salt to get back the hexadecimal string.
226+
//
227+
// Each hex nibble is encoded as an integer in range [16, 31].
226228
func (h *HashID) EncodeHex(hex string) (string, error) {
227229
nums := make([]int, len(hex))
228230

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

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

0 commit comments

Comments
 (0)