kagi: github.com/h4ckedneko/kagi Index | Files

package kagi

import "github.com/h4ckedneko/kagi"

Package kagi is a simple utility to manage application keys in Go.

It enables the application to generate and use a secure key for production, while allowing the developers to use hardcoded key that can be shared for the whole team during development.

Here is a basic example for this package:

package main

import (
	"fmt"

	"github.com/h4ckedneko/kagi"
)

func main() {
	// Generate a new secure key.
	key := kagi.New(32)
	fmt.Println(key)

	// Decode a generated key.
	keyd := kagi.Decode(key)
	fmt.Println(string(keyd))

	// Decode a hardcoded key.
	keyd = kagi.Decode("abc123")
	fmt.Println(string(keyd))
}

See https://github.com/h4ckedneko/kagi/tree/master/examples for more advanced real-world examples.

Index

Package Files

doc.go kagi.go

func Decode Uses

func Decode(key string) []byte

Decode decodes an application key and returns its raw bytes. It accepts application key that was generated by New or application key that was manually hardcoded.

func New Uses

func New(size int) string

New returns a randomly generated secure application key.

func New16 Uses

func New16() string

New16 is a helper for New that returns a 16-bytes application key.

func New32 Uses

func New32() string

New32 is a helper for New that returns a 32-bytes application key.

func New64 Uses

func New64() string

New64 is a helper for New that returns a 64-bytes application key.

func New8 Uses

func New8() string

New8 is a helper for New that returns an 8-bytes application key.

Package kagi imports 2 packages (graph). Updated 2020-09-28. Refresh now. Tools for package owners.