uuidapikey

package module
v0.0.0-...-27b9fd9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

uuidapikey

A Base32-Crockford encoded API Key generator, validator and converter to turn UUIDs into human readable API Keys for Golang.

Installation

You can install this with go get.

go get "github.com/tirpitz0509/uuidapikey"

Usage

Create a pair of keys
package main

import (
	"fmt"

	"github.com/tirpitz0509/uuidapikey"
)

func main() {

	fmt.Println(uuidapikey.Create())
}

Output:

{ "apiKey":"38QARV0-1ET0G6Z-2CJD9VA-2ZZAR0X", 
"uuid":"d1756360-5da0-40df-9926-a76abff5601d" }
Validate your UUID
uuidString := "d1756360-5da0-40df-9926-a76abff5601d"
fmt.Println(uuidapikey.IsUUID(uuidString)) // returns true
Validate your API Key
apiKeyString := "38QARV0-1ET0G6Z-2CJD9VA-2ZZAR0X"
fmt.Println(uuidapikey.IsAPIKey(apiKeyString)) // returns true
Convert UUID into API Key
uuidString := "d1756360-5da0-40df-9926-a76abff5601d"
fmt.Println(uuidapikey.ToAPIKey(uuidString))

Output:

38QARV0-1ET0G6Z-2CJD9VA-2ZZAR0X
Convert API Key into UUID
apiKeyString := "38QARV0-1ET0G6Z-2CJD9VA-2ZZAR0X"
fmt.Println(uuidapikey.ToUUID(apiKeyString))

Output:

d1756360-5da0-40df-9926-a76abff5601d

Issues

Currently, Issue Tracking is done via GitHub Issues.

Documentation

Overview

Package uuidapikey contains generator, validator, and converter that transforms UUIDs into human-readable Base32-Crockford encoded API Keys

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(uuid, apiKey string) (bool, error)

Check will verify both UUID and API Key, with either given

func Create

func Create() (string, error)

Create will create new UUID and API Key

func Decode

func Decode(decodedString string) string

Decode will convert your given string into original UUID part string

func Encode

func Encode(number uint64) string

Encode will convert your given int64 into base32 crockford encoding format

func IsAPIKey

func IsAPIKey(apiKey string) (bool, error)

IsAPIKey will verify given API Key

func IsUUID

func IsUUID(uuid string) (bool, error)

IsUUID will verify given UUID

func ToAPIKey

func ToAPIKey(uuid string) (string, error)

ToAPIKey will convert given UUID to API Key

func ToUUID

func ToUUID(apiKey string) (string, error)

ToUUID will convert given API Key to UUID

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL