Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Go package uniuri generates random strings good for use in URIs to identify unique objects.

License

NotificationsYou must be signed in to change notification settings

dchest/uniuri

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

import"github.com/dchest/uniuri"

Package uniuri generates random strings good for use in URIs to identifyunique objects.

Example usage:

s:=uniuri.New()// s is now "apHCJBl7L1OmC57n"

A standard string created by New() is 16 bytes in length and consists ofLatin upper and lowercase letters, and numbers (from the set of 62 allowedcharacters), which means that it has ~95 bits of entropy. To get moreentropy, you can use NewLen(UUIDLen), which returns 20-byte string, giving~119 bits of entropy, or any other desired length.

Functions read from crypto/rand random source, and panic if they fail toread from it.

Constants

const (// StdLen is a standard length of uniuri string to achive ~95 bits of entropy.StdLen=16// UUIDLen is a length of uniuri string to achive ~119 bits of entropy, closest// to what can be losslessly converted to UUIDv4 (122 bits).UUIDLen=20)

Variables

varStdChars= []byte("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")

StdChars is a set of standard characters allowed in uniuri string.

Functions

func New

funcNew()string

New returns a new random string of the standard length, consisting ofstandard characters.

func NewLen

funcNewLen(lengthint)string

NewLen returns a new random string of the provided length, consisting ofstandard characters.

func NewLenChars

funcNewLenChars(lengthint,chars []byte)string

NewLenChars returns a new random string of the provided length, consistingof the provided byte slice of allowed characters (maximum 256).

Public domain dedication

Written in 2011-2014 by Dmitry Chestnykh

The author(s) have dedicated all copyright and related andneighboring rights to this software to the public domainworldwide. Distributed without any warranty.http://creativecommons.org/publicdomain/zero/1.0/

About

Go package uniuri generates random strings good for use in URIs to identify unique objects.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp