Skip to content

Latest commit

 

History

History
30 lines (21 loc) · 770 Bytes

README.md

File metadata and controls

30 lines (21 loc) · 770 Bytes

Bijectiv Build Status GoDoc

A Bijective Encoding Function implementation, useful for URL shorteners.

Installation

go get github.com/leonardoeloy/bijectiv

Usage

package main

import (
	"github.com/leonardoeloy/bijectiv"
	"fmt"
)

func main() {
	b := bijectiv.New()
	fmt.Printf("Encoded value of 100 is %s\n", b.Encode(100))
	fmt.Printf("Decoded value of 'bM' is %d\n", b.Decode("bM"))

	b = bijectiv.NewAlphabet("MYRESTRICTEDALPHABET")
	fmt.Printf("Encoded value of 100 with custom alphabet is %s\n", b.Encode(100))
}