|
@@ -54,6 +54,7 @@ import (
|
|
|
"crypto/tls"
|
|
"crypto/tls"
|
|
|
"crypto/x509"
|
|
"crypto/x509"
|
|
|
"encoding/base64"
|
|
"encoding/base64"
|
|
|
|
|
+ "encoding/hex"
|
|
|
"errors"
|
|
"errors"
|
|
|
"fmt"
|
|
"fmt"
|
|
|
"math/big"
|
|
"math/big"
|
|
@@ -150,14 +151,14 @@ func MakeRandomPeriod(min, max time.Duration) (duration time.Duration) {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// MakeRandomString returns a base64 encoded random string. byteLength
|
|
|
|
|
|
|
+// MakeRandomString returns a hex encoded random string. byteLength
|
|
|
// specifies the pre-encoded data length.
|
|
// specifies the pre-encoded data length.
|
|
|
func MakeRandomString(byteLength int) (string, error) {
|
|
func MakeRandomString(byteLength int) (string, error) {
|
|
|
bytes, err := MakeSecureRandomBytes(byteLength)
|
|
bytes, err := MakeSecureRandomBytes(byteLength)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return "", ContextError(err)
|
|
return "", ContextError(err)
|
|
|
}
|
|
}
|
|
|
- return base64.RawStdEncoding.EncodeToString(bytes), nil
|
|
|
|
|
|
|
+ return hex.EncodeToString(bytes), nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func DecodeCertificate(encodedCertificate string) (certificate *x509.Certificate, err error) {
|
|
func DecodeCertificate(encodedCertificate string) (certificate *x509.Certificate, err error) {
|