diff options
Diffstat (limited to 'shrine/utils/crypto/refs.go')
| -rw-r--r-- | shrine/utils/crypto/refs.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/shrine/utils/crypto/refs.go b/shrine/utils/crypto/refs.go new file mode 100644 index 0000000..e038004 --- /dev/null +++ b/shrine/utils/crypto/refs.go @@ -0,0 +1,25 @@ +package crypto + +import ( + "crypto/rand" + "time" +) + +const alphabet = "abcdefghijklmnopqrstuvwxyz0123456789" + +func randomString(length int) string { + bytes := make([]byte, length) + rand.Read(bytes) + for i := range bytes { + bytes[i] = alphabet[bytes[i]%byte(len(alphabet))] + } + return string(bytes) +} + +func SystemRef() string { + return time.Now().Format("020106") + randomString(8) +} + +func Ref() string { + return randomString(12) +}
\ No newline at end of file |
