Browse Source

Use hex instead of base64 encoding for server secret values
* Avoids complications with passing values in URLs, etc.

Rod Hynes 10 năm trước cách đây
mục cha
commit
865699cc67
1 tập tin đã thay đổi với 3 bổ sung2 xóa
  1. 3 2
      psiphon/utils.go

+ 3 - 2
psiphon/utils.go

@@ -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) {