randkey

package
v1.100.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package randkey provides utility functions to generate random uint64 keys in different formats.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RandKey

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

RandKey stores the random key.

func New

func New() *RandKey

New generates a new uint64 random key.

Example
package main

import (
	"fmt"

	"github.com/Vonage/gosrvlib/pkg/randkey"
)

func main() {
	// generate a new key
	k := randkey.New()

	fmt.Println(k)
}
Output:

func (*RandKey) Hex

func (sk *RandKey) Hex() string

Hex returns a fixed-length 16 digits hexadecimal string key.

Example
package main

import (
	"fmt"

	"github.com/Vonage/gosrvlib/pkg/randkey"
)

func main() {
	// generate a new random key as fixed-length 16 digits hexadecimal string key.
	k := randkey.New().Hex()

	fmt.Println(k)
}
Output:

func (*RandKey) Key

func (sk *RandKey) Key() uint64

Key returns a uint64 key.

Example
package main

import (
	"fmt"

	"github.com/Vonage/gosrvlib/pkg/randkey"
)

func main() {
	// generate a new random key as uint64
	k := randkey.New().Key()

	fmt.Println(k)
}
Output:

func (*RandKey) String

func (sk *RandKey) String() string

String returns a variable-length string key.

Example
package main

import (
	"fmt"

	"github.com/Vonage/gosrvlib/pkg/randkey"
)

func main() {
	// generate a new random key as 36-char encoded string
	k := randkey.New().String()

	fmt.Println(k)
}
Output:

Jump to

Keyboard shortcuts

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