randkey

package
v1.74.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package randkey creates a random uint64 key.

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