Add Base64URLString to SHA256Hash

This commit is contained in:
Andrew Ayer 2023-02-03 13:57:53 -05:00
parent 57e9458ce5
commit 5236ac5ae8
1 changed files with 5 additions and 0 deletions

View File

@ -259,6 +259,11 @@ func (s SHA256Hash) Base64String() string {
return base64.StdEncoding.EncodeToString(s[:]) return base64.StdEncoding.EncodeToString(s[:])
} }
// Returns the raw base64url representation of this SHA256Hash.
func (s SHA256Hash) Base64URLString() string {
return base64.RawURLEncoding.EncodeToString(s[:])
}
// MarshalJSON implements the json.Marshaller interface for SHA256Hash. // MarshalJSON implements the json.Marshaller interface for SHA256Hash.
func (s SHA256Hash) MarshalJSON() ([]byte, error) { func (s SHA256Hash) MarshalJSON() ([]byte, error) {
return []byte(`"` + s.Base64String() + `"`), nil return []byte(`"` + s.Base64String() + `"`), nil