@@ -46,6 +46,14 @@ func (m *SigningMethodHMAC) Alg() string {
46
46
}
47
47
48
48
// Verify implements token verification for the SigningMethod. Returns nil if the signature is valid.
49
+ // Key must be []byte
50
+ // Note it is not advised to provide a []byte which was converted from a 'human readable' string using a subset of ASCII characters.
51
+ // To maximize entropy, you should ideally be providing a []byte key which was produced from a cryptographically random source.
52
+ // i.e. crypto/rand https://pkg.go.dev/crypto/rand#Read
53
+ //
54
+ // Storing keys in the environment can be done by base64 encoding the cryptographically random []byte.
55
+ // Reading keys from the environment can be done by base64 decoding the environment variable to retrieve the original cryptographically random []byte.
56
+ // i.e. encoding/base64 https://pkg.go.dev/encoding/base64#Encoding.DecodeString
49
57
func (m * SigningMethodHMAC ) Verify (signingString , signature string , key interface {}) error {
50
58
// Verify the key is the right type
51
59
keyBytes , ok := key .([]byte )
@@ -79,6 +87,13 @@ func (m *SigningMethodHMAC) Verify(signingString, signature string, key interfac
79
87
80
88
// Sign implements token signing for the SigningMethod.
81
89
// Key must be []byte
90
+ // Note it is not advised to provide a []byte which was converted from a 'human readable' string using a subset of ASCII characters.
91
+ // To maximize entropy, you should ideally be providing a []byte key which was produced from a cryptographically random source.
92
+ // i.e. crypto/rand https://pkg.go.dev/crypto/rand#Read
93
+ //
94
+ // Storing keys in your environment can be done by base64 encoding the cryptographically random []byte.
95
+ // Reading keys from the environment can be done by base64 decoding the environment variable to retrieve the original cryptographically random []byte.
96
+ // i.e. encoding/base64 https://pkg.go.dev/encoding/base64#Encoding.DecodeString
82
97
func (m * SigningMethodHMAC ) Sign (signingString string , key interface {}) (string , error ) {
83
98
if keyBytes , ok := key .([]byte ); ok {
84
99
if ! m .Hash .Available () {
0 commit comments