HMAC + SHA256 jwt secret length

cryptographyhashjwt

I will be signing a token with SHA256 and I am wondering on the length of the secret I should put. Does having a secret key length over 256 bits have any benefits if I am using sha256. So if my key is 300 bits long is this more secure?

Best Answer

The length of the key has to be <= 512 bits because that is the size of the pads. If someone is trying to brute force your key, having a key size of 512 bits will be the most secure.

So to answer your question. Yes, having a key length 300 bits is more secure than one with length 256 bits.