mirror of
https://github.com/documize/community.git
synced 2025-07-23 07:09:43 +02:00
GenerateRandom function added
This commit is contained in:
parent
7d38102eb6
commit
6cc6b6d70f
1 changed files with 9 additions and 9 deletions
|
@ -1,11 +1,11 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
|
@ -22,17 +22,17 @@ import (
|
|||
|
||||
// GenerateRandomPassword provides a string suitable for use as a password.
|
||||
func GenerateRandomPassword() string {
|
||||
c := 5
|
||||
b := make([]byte, c)
|
||||
_, err := rand.Read(b)
|
||||
log.IfErr(err)
|
||||
return hex.EncodeToString(b)
|
||||
return GenerateRandom(5)
|
||||
}
|
||||
|
||||
// GenerateSalt provides a string suitable for use as a salt value.
|
||||
func GenerateSalt() string {
|
||||
c := 20
|
||||
b := make([]byte, c)
|
||||
return GenerateRandom(20)
|
||||
}
|
||||
|
||||
// GenerateRandom returns a string of the specified length using crypo/rand
|
||||
func GenerateRandom(size int) string {
|
||||
b := make([]byte, size)
|
||||
_, err := rand.Read(b)
|
||||
log.IfErr(err)
|
||||
return hex.EncodeToString(b)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue