For token based authentication Microsoft.IdentityModel.Tokens
provides a list of security algorithms that can be used to create SigningCredentials
:
string secretKey = "MySuperSecretKey"; byte[] keybytes = Encoding.ASCII.GetBytes(secretKey); SecurityKey securityKey = new SymmetricSecurityKey(keybytes); SigningCredentials signingCredentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256); SigningCredentials signingCredentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256Signature);
What is the difference between HmacSha256 and HmacSha256Signature? When would you use the signature one instead of the non-signature one?**
There are other algorithms "non signature" and "signature" algorithms as well - RsaSha256 and RsaSha256