commit
29588318d5
@ -28,14 +28,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Standard length of uniuri string to achive ~95 bits of entropy.
|
// StdLen is a standard length of uniuri string to achive ~95 bits of entropy.
|
||||||
StdLen = 16
|
StdLen = 16
|
||||||
// Length of uniurl string to achive ~119 bits of entropy, closest
|
// UUIDLen is a length of uniuri string to achive ~119 bits of entropy, closest
|
||||||
// to what can be losslessly converted to UUIDv4 (122 bits).
|
// to what can be losslessly converted to UUIDv4 (122 bits).
|
||||||
UUIDLen = 20
|
UUIDLen = 20
|
||||||
)
|
)
|
||||||
|
|
||||||
// Standard characters allowed in uniuri string.
|
// StdChars is a set of standard characters allowed in uniuri string.
|
||||||
var StdChars = []byte("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")
|
var StdChars = []byte("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")
|
||||||
|
|
||||||
// New returns a new random string of the standard length, consisting of
|
// New returns a new random string of the standard length, consisting of
|
||||||
|
@ -34,13 +34,13 @@ func TestNew(t *testing.T) {
|
|||||||
|
|
||||||
// Generate 1000 uniuris and check that they are unique
|
// Generate 1000 uniuris and check that they are unique
|
||||||
uris := make([]string, 1000)
|
uris := make([]string, 1000)
|
||||||
for i, _ := range uris {
|
for i := range uris {
|
||||||
uris[i] = New()
|
uris[i] = New()
|
||||||
}
|
}
|
||||||
for i, u := range uris {
|
for i, u := range uris {
|
||||||
for j, u2 := range uris {
|
for j, u2 := range uris {
|
||||||
if i != j && u == u2 {
|
if i != j && u == u2 {
|
||||||
t.Fatalf("not unique: %d:%q and %d:%q", i, j, u, u2)
|
t.Fatalf("not unique: %d:%q and %d:%q", i, u, j, u2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user