// Sign takes a secret and signs the ClaimSet with HMAC SHA-256. It returns
// the base64 encoded byte sequence of the signature or an error in case of
// problems marshalling the ClaimSet to JSON.
Sign takes a secret and signs the ClaimSet with HMAC SHA-256. It returns
the base64 encoded byte sequence of the signature or an error in case of
problems marshalling the ClaimSet to JSON.
// Sign takes a secret and signs the ClaimSet with HMAC SHA - 256 . It returns // the base64 encoded byte sequence of the signature or an error in case of // problems marshalling the ClaimSet to JSON .
func (c ClaimSet) Sign(secret string) (string, error) {
	hdr := `{"typ":"JWT","alg":"HS256"}`
	claims, err := json.Marshal(c)
	if err != nil {
		return "", err
	}
	header := base64Encode([]byte(hdr))
	payload := base64Encode(claims)
	return sign(header+"."+payload, secret), nil
}
func ( c ClaimSet ) Sign ( secret string ) ( string , error ) { hdr := `{"typ":"JWT","alg":"HS256"}` claims , err := json . Marshal ( c ) if err != nil { return " " , err } header := base64Encode ( [ ] byte ( hdr ) ) payload := base64Encode ( claims ) return sign ( header + " " + payload , secret ) , nil }
Sign takes a secret and signs the ClaimSet with HMAC SHA-256.
Sign takes a secret and signs the ClaimSet with HMAC SHA - 256 .
// XXX hdr directly as base64?