This generates a 256-bit (32-byte) random string encoded in Base64. This is the ideal length for HS256. 2. Using Node.js Crypto
// Generate a 32-byte secret key in base64 const secretKey = crypto.randomBytes(32).toString('base64'); console.log(secretKey); secret key generator for jwt