// Verify checks the validity of the token and verifies the integrity with
// HMAC SHA-256 and the given secret.
Verify checks the validity of the token and verifies the integrity with
HMAC SHA-256 and the given secret.
// Verify checks the validity of the token and verifies the integrity with // HMAC SHA - 256 and the given secret .
func Verify(token, secret string) bool {
	parts := strings.Split(token, ".")
	if len(parts) != 3 {
		return false
	}
	rawHeader, err := base64Decode(parts[0])
	if err != nil {
		return false
	}
	var hdr Header
	if json.Unmarshal([]byte(rawHeader), &hdr) != nil {
		return false
	}
	if hdr.Type != "JWT" {
		return false
	}
	if hdr.Algorithm != "HS256" {
		return false
	}
	return signature(parts[0]+"."+parts[1], secret) == parts[2]
}
func Verify ( token , secret string ) bool { parts := strings . Split ( token , " " ) if len ( parts ) != 3 { return false } rawHeader , err := base64Decode ( parts [ 0 ] ) if err != nil { return false } var hdr Header if json . Unmarshal ( [ ] byte ( rawHeader ) , & hdr ) != nil { return false } if hdr . Type != " " { return false } if hdr . Algorithm != " " { return false } return signature ( parts [ 0 ] + " " + parts [ 1 ] , secret ) == parts [ 2 ] }
Verify checks the validity of the token and verifies the integrity with
HMAC SHA-256 and the given secret.
Verify checks the validity of the token and verifies the integrity with HMAC SHA - 256 and the given secret .