enc_uuid

package module
v0.0.0-...-c181b1f Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

README

golang-encrypted-uuid Build status

Encrypt a UUID (common use case as tracking cookie)

Example: creating

generator := enc_uuid.New([]byte("mysecret90123456"), true)
u := generator.New()
log.Println(u.ToString()) // Encrypted string

Example: reading

generator := enc_uuid.New([]byte("mysecret90123456"), true)
parsed, _ := generator.Parse("T5LvxuSpeC0g2VglOnOACOzuFP0wmH04l49fQmSWR5+kpIXvGXzO0g==")
parsedStr, _ := parsed.UuidStr(generator)
log.Println(parsedStr) // Decrypted hex string representation of the uuid v4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EncUuid

type EncUuid struct {
	// contains filtered or unexported fields
}

func (*EncUuid) AdditionalDataStr

func (u *EncUuid) AdditionalDataStr(e *EncUuidGenerator) (string, error)

func (*EncUuid) SetAdditionalData

func (u *EncUuid) SetAdditionalData(e *EncUuidGenerator, additionalData string) error

func (*EncUuid) ToString

func (u *EncUuid) ToString() string

func (*EncUuid) UuidStr

func (u *EncUuid) UuidStr(e *EncUuidGenerator) (string, error)

type EncUuidGenerator

type EncUuidGenerator struct {
	// contains filtered or unexported fields
}

func New

func New(secret []byte, gracefulFallback bool) *EncUuidGenerator

func (*EncUuidGenerator) Decrypt

func (e *EncUuidGenerator) Decrypt(text string) ([]byte, error)

func (*EncUuidGenerator) Encrypt

func (e *EncUuidGenerator) Encrypt(text []byte) (string, error)

func (*EncUuidGenerator) New

func (e *EncUuidGenerator) New() *EncUuid

func (*EncUuidGenerator) NewWithAdditionalData

func (e *EncUuidGenerator) NewWithAdditionalData(additionalData string) *EncUuid

func (*EncUuidGenerator) Parse

func (e *EncUuidGenerator) Parse(in string) (*EncUuid, error)

Jump to

Keyboard shortcuts

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