30 lines
489 B
Go
30 lines
489 B
Go
package kvstore
|
|
|
|
/*
|
|
Copyright (c) 2022, John David Lee
|
|
All rights reserved.
|
|
|
|
This source code is licensed under the BSD-style license found in the
|
|
LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"encoding/hex"
|
|
mrand "math/rand"
|
|
)
|
|
|
|
func _b(in string) []byte {
|
|
return []byte(in)
|
|
}
|
|
|
|
func randString() string {
|
|
buf := make([]byte, 1+mrand.Intn(20))
|
|
rand.Read(buf)
|
|
return hex.EncodeToString(buf)
|
|
}
|
|
|
|
func randBytes() []byte {
|
|
return _b(randString())
|
|
}
|