RandomCode

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

README

RandomCode

Easily generate random code

It is usually used for generating verification codes

Requirement

  • Go: 1.0.0+

Simple Usage

package main

import "git.ghink.net/ghink/RandomCode"

func main() {
   RandomCode.Number(6)
}

Documentation

Index

Constants

View Source
const DefaultSymbols = "!@#$%^&*?"

DefaultSymbols is the default charset of symbols

Variables

This section is empty.

Functions

func Alpha

func Alpha(digit int, useLower, useUpper bool) string

Alpha generates a random code with alpha only

func Code

func Code(config Options) string

Code generates a random code

func Mixed

func Mixed(digit int, useNumbers, useLower, useUpper, useSymbols bool) string

Mixed generates a random code with mixed charset

func Number

func Number(digit int) string

Number generates a random code with num only

Types

type Options

type Options struct {
	Digit         int    // Digit of the random code
	UseNumbers    bool   // Use numbers or not
	UseLowercase  bool   // Use lowercase or not
	UseUppercase  bool   // Use uppercase or not
	UseSymbols    bool   // Use symbols or not
	CustomSymbols string // Charset of custom symbols
	ExcludeChars  string // Charset to exclude
}

Options is the option struct to generate random code

Jump to

Keyboard shortcuts

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