uniuri

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

Github星跟蹤圖

Package uniuri

Build Status

import "github.com/dchest/uniuri"

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

Example usage:

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

A standard string created by New() is 16 bytes in length and consists of
Latin upper and lowercase letters, and numbers (from the set of 62 allowed
characters), which means that it has ~95 bits of entropy. To get more
entropy, 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 to
read 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

var StdChars = []byte("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")

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

Functions

func New

func New() string

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

func NewLen

func NewLen(length int) string

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

func NewLenChars

func NewLenChars(length int, chars []byte) string

NewLenChars returns a new random string of the provided length, consisting
of 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 and
neighboring rights to this software to the public domain
worldwide. Distributed without any warranty.
http://creativecommons.org/publicdomain/zero/1.0/

主要指標

概覽
名稱與所有者dchest/uniuri
主編程語言Go
編程語言Go (語言數: 1)
平台
許可證Creative Commons Zero v1.0 Universal
所有者活动
創建於2011-04-05 15:58:20
推送於2022-12-01 13:00:52
最后一次提交2022-10-07 14:28:17
發布數1
最新版本名稱v1.2.0 (發布於 )
第一版名稱v1.2.0 (發布於 )
用户参与
星數452
關注者數7
派生數42
提交數56
已啟用問題?
問題數6
打開的問題數0
拉請求數8
打開的拉請求數0
關閉的拉請求數5
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?