internal static HeaderDto DeserializeHeader(string input) { var jsonSerializer = new DataContractJsonSerializer(typeof(HeaderDto)); var headerJson = Base64UrlEncoding.Decode(input); using (var stream = new MemoryStream(headerJson)) { return(jsonSerializer.ReadObject(stream) as HeaderDto); } }
internal static PayloadDto DeserializePayload(string input, string secretKey, string tokenIdentifier) { var headerEncrypted = Base64UrlEncoding.Decode(input); var decrypted = AesEncryption.DecryptPayload(secretKey, tokenIdentifier, headerEncrypted); var jsonSerializer = new DataContractJsonSerializer(typeof(Model.PayloadDto), new DataContractJsonSerializerSettings() { UseSimpleDictionaryFormat = true }); using (var stream = new MemoryStream(decrypted)) { return(jsonSerializer.ReadObject(stream) as PayloadDto); } }
public void Decode(string expectedOutput, string input) { var bytes = Base64UrlEncoding.Decode(input); Assert.Equal(expectedOutput, Encoding.UTF8.GetString(bytes)); }