RSA256 to generate signature token

I have written javascript code as below to make in SHA256 with same credential which is mentioned in jwt.io and working fine but i need in RSA256 to generate signature token.

 function aaa(message,secret) {
 var hash = CryptoJS.HmacSHA256("message", "secret");
var hashInBase64 = CryptoJS.enc.Base64.stringify(hash);
return hashInBase64
 }

The information you provided is not sufficient to understand what’s the exact issue. It seems you’re trying to use lower-level libraries to construct the several components of a JWT token. This is not recommended and you should be using a library specifically aimed at creating and validating JWT’s.

You can check the Libraries section of jwt.io to find a library for the platform that you’re targeting. In general HS256 and RS256 are the most common algorithms supported so you should not have a problem in finding a library.