1
0
mirror of https://github.com/taigrr/pastebin synced 2026-04-15 22:10:48 -07:00

Initial Commit

This commit is contained in:
2017-07-02 23:42:34 -07:00
commit 3c42d7d878
13 changed files with 369 additions and 0 deletions

19
utils.go Normal file
View File

@@ -0,0 +1,19 @@
package main
import (
"crypto/rand"
)
const (
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
)
// RandomString ...
func RandomString(length int) string {
bytes := make([]byte, length)
rand.Read(bytes)
for i, b := range bytes {
bytes[i] = alphabet[b%byte(len(alphabet))]
}
return string(bytes)
}