mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2025-12-31 10:08:31 -05:00
23 lines
472 B
Go
23 lines
472 B
Go
/*
|
|
* Copyright 2017 Kopano
|
|
*
|
|
* Use of this source code is governed by a MIT license
|
|
* that can be found in the LICENSE.txt file.
|
|
*
|
|
*/
|
|
|
|
package rndm
|
|
|
|
import (
|
|
"encoding/base64"
|
|
)
|
|
|
|
// GenerateRandomString returns a URL-safe, base64 encoded securely generated
|
|
// random string. It will panic if the system fails to provide secure random
|
|
// data.
|
|
func GenerateRandomString(s int) string {
|
|
b := GenerateRandomBytes(s)
|
|
|
|
return base64.RawURLEncoding.EncodeToString(b)
|
|
}
|