cryptorand

package
v0.27.3 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Numeric includes decimal numbers (0-9)
	Numeric = "0123456789"

	// Upper is uppercase characters in the Latin alphabet
	Upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

	// Lower is lowercase characters in the Latin alphabet
	Lower = "abcdefghijklmnopqrstuvwxyz"

	// Alpha is upper or lowercase alphabetic characters
	Alpha = Upper + Lower

	// Default is uppercase, lowercase, or numeric characters
	Default = Numeric + Alpha

	// Hex is hexadecimal lowercase characters
	Hex = "0123456789abcdef"

	// Human creates strings which are easily distinguishable from
	// others created with the same charset. It contains most lowercase
	// alphanumeric characters without 0,o,i,1,l.
	Human = "23456789abcdefghjkmnpqrstuvwxyz"
)

Charsets

Variables

This section is empty.

Functions

func Element added in v0.5.11

func Element[T any](s []T) (out T, err error)

Element returns a random element of the slice. An error will be returned if the slice has no elements in it.

func Float64

func Float64() (float64, error)

Float64 returns a random number in [0.0,1.0) as a float64.

func HexString

func HexString(size int) (string, error)

HexString returns a hexadecimal string of given length.

func Int63

func Int63() (int64, error)

Int64 returns a non-negative random 63-bit integer as a int64.

func Intn

func Intn(max int) (int, error)

Intn returns a non-negative integer in [0,max) as an int.

func Sha1String

func Sha1String() (string, error)

Sha1String returns a 40-character hexadecimal string, which matches the length of a SHA-1 hash (160 bits).

func String

func String(size int) (string, error)

String returns a random string using Default.

func StringCharset

func StringCharset(charSetStr string, size int) (string, error)

StringCharset generates a random string using the provided charset and size.

Types

This section is empty.

Jump to

Keyboard shortcuts

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

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy