I want to encrypt my JSON object into a JWE token. I am using the JOSE NuGet SDK with C# language. I am using A256KW JweAlgorithm for secret key and A256GCM for JweEncryption. Could anyone please help me find out what I am doing wrong?
string key = "Some Key";
// Create Security key using private key above:
// not that latest version of JWT using Microsoft namespace instead of System
var securityKey = new Microsoft.IdentityModel.Tokens.SymmetricSecurityKey(Encoding.UTF8.GetBytes(key));
//Some PayLoad that contain information about the customer
var payload = new JwtPayload
{
{ "page ", "2 "},
{ "sc", "http://dummy.com/"},
};
var payload1 = Newtonsoft.Json.JsonConvert.SerializeObject(anyPayJson);
string token_1 = JWE.Encrypt(payload1, new[] { new JweRecipient(JweAlgorithm.A256KW, key, null) }, JweEncryption.A256GCM);
I am new in JOSE JWT and have no idea how to use JWE algo to the wrap secret key. I am getting error while processing it:
AesKeyWrap management algorithm expects key to be byte[] array.