DEV Community

Generate a Random JWT Secret Key

Tonny Kirwa on December 16, 2023

To generate a random JWT secret key, you can use a tool like Node.js to create a random string. Here's a simple example: Open your terminal or co...
Collapse
 
soares100 profile image
Irinaldo Soares

Thanks!

Collapse
 
sergio_jz profile image
Sergio J

Thanks!!!

Collapse
 
gadrawingz profile image
Gad Iradufasha

Helpful in my job!

Collapse
 
codesimonwise profile image
Simon Rabuogi

Thanks for this mate

Collapse
 
krasezzza profile image
Krasimir Tsvetanov

Super useful, thanks!

Collapse
 
tkirwa profile image
Tonny Kirwa

I'm glad to hear it helped you 🙏🏾

Collapse
 
kevdubinks profile image
kevdubinks

merci cela m'a beaucoup aidé

Collapse
 
tkirwa profile image
Tonny Kirwa

Bienvenue 😀 N'hésitez pas à le partager avec vos amis.

Collapse
 
climontectos profile image
Carlos Limón

Excelent

Collapse
 
tkirwa profile image
Tonny Kirwa

Thanks 😀

Collapse
 
louis_pierrefrancoisdar profile image
Louis Pierre Francois Darell Musette

Hello, thanks !
But one question, how will I know when it expires?
const token= jwt.sign({_id:this._id},process.env.JWTPRIVATEKEY,{ expiresIn:"EXPIRATIONTIME"});

Collapse
 
kabir98owo profile image
Kabir98owo

Pieces.app

Collapse
 
thaura profile image
james mweni

Aaahh nicee

Collapse
 
chubiao_huangmrhuang_ profile image
chubiao huang (MR HUANG)

This is a neat trick! I always wondered how to quickly generate a strong JWT secret key. This Node.js snippet is super useful, thanks for sharing! Gonna save this for later.

Collapse
 
chubiao_huangmrhuang_ profile image
chubiao huang (MR HUANG)

Okay, this JWT secret key generator seems pretty handy! Looks like a quick way to create secure keys without all the fuss. Definitely gonna bookmark this for future projects.