How to generate a secret?
How to generate a secret?
Is the length of the secret fixed?
Hi, What kind of algorithm you're using Symmetric or Asymmetric?
String-based secret is used in the former, here's how it works: the string converted to a byte array. The max size is Array.Length which is Int32.
However, the modern approach would be using the latter. Which doesn't use a secret, it uses a certificate instead.
In the examples there is a secret key like: var secret = "GQDstcKsx0NHjPOuXOYg5MbeJ1XT0uFiwDVvVBrk";
Looks like this secret is in base64 format. Can I use Guid.NewGuid() instead?
I don't know how I can get a secret like the secret in the example.
I don't think it's in bas64. I'm not sure where it's coming from, it was added in the 4th commit to this repo more than 5 years ago by prior maintainer. Maybe it's just a random string, maybe something else. It must be a random string, GUID also should work. I'm not an expert in cryptography, I would suggest additional reading. And overall I would suggest using the asymmetric algorithm with a certificate aka PKI.
Thank you for your reply. It's very helpful.
You're welcome!