Skip to content

Instantly share code, notes, and snippets.

@jkuemerle
Last active December 30, 2015 04:29
Show Gist options
  • Select an option

  • Save jkuemerle/7776705 to your computer and use it in GitHub Desktop.

Select an option

Save jkuemerle/7776705 to your computer and use it in GitHub Desktop.
EncryptedType Test Implementation
[EncryptedType]
public class EncTest {
public string ID { get; set; }
[EncryptedValue]
public string SSN { get; set; }
public string IntegrityValue() { return this.ID; }
public EncTest() {
this.ID = Guid.NewGuid().ToString();
}
}
[Test]
public void TestAspect()
{
var n = new EncTest();
var s = new CeloClavis.TestServer();
((IEncryptedType)n).KeyServer = s;
((IEncryptedType)n).EncryptionKeys = s.Map;
((IEncryptedType)n).Integrity("SSN", n.IntegrityValue);
n.SSN = "111-11-1111";
Assert.AreNotEqual("111-11-1111", n.SSN);
}
[Test]
public void TestDecryption()
{
var n = new EncTest();
var s = new CeloClavis.TestServer();
((IEncryptedType)n).KeyServer = s;
((IEncryptedType)n).EncryptionKeys = s.Map;
((IEncryptedType)n).Integrity(() => n.SSN, n.IntegrityValue);
n.SSN = "111-11-1111";
Assert.AreEqual("111-11-1111", ((IEncryptedType)n).AsClear(() => n.SSN));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment