public void VerifySignature_WithCorrectValue() { //Arrange string unsignedSessionData = Convert.ToBase64String(sessionValue); string signedSessionData = signatureHelper.CreateSignature(sessionValue); //Act bool result = signatureHelper.VerifySignature(unsignedSessionData, signedSessionData); //Assert Assert.True(result); }
public void VerifySignature_WithCorrectValue() { //Arrange string unsignedEncodedValue = Convert.ToBase64String(actualValue); string signature = signatureHelper.CreateSignature(actualValue); //Act bool result = signatureHelper.VerifySignature(unsignedEncodedValue, signature); //Assert Assert.True(result); }
public async Task <byte[]> GetAsync(string key, CancellationToken token = default) { var sessionData = await _cache.GetAsync(key, token); if (sessionData == null || sessionData.Length == 0) { return(sessionData); } var signedValue = Encoding.UTF8.GetString(sessionData).Split("."); var encodedValue = signedValue.First(); var signature = signedValue.Last(); var signatureIsValid = _signatureHelper.VerifySignature(encodedValue, signature); if (!signatureIsValid) { throw new Exception("Session Signature is invalid"); } return(Convert.FromBase64String(encodedValue)); }