private static void Main(string[] args) { // Based on feedback we will be distributing CipherObject as its own // NuGet package shortly which will also have the same Seal/Unseal API // as shown below. For now the same API exists in CipherDB // Init Console.WriteLine("Simple 'hello world' style example for CipherDB/CipherObject" + Environment.NewLine); var patient = new Patient { Name = "John Doe", SocialSecurityNumber = "555-55-5555" }; Console.WriteLine($"Clear Object : {JsonConvert.SerializeObject(patient)}" + Environment.NewLine); /////////////////////////////////////////////////////////////////// // SEAL: Encrypt object here automagically /////////////////////////////////////////////////////////////////// Console.WriteLine("=> Seal() performed on object" + Environment.NewLine); patient.Seal(); // <===== via extension method // Crypteron.CipherObject.Seal(patient); // <===== via explicit API (identical to the above) Console.WriteLine($"Sealed Object: {JsonConvert.SerializeObject(patient)}" + Environment.NewLine); /////////////////////////////////////////////////////////////////// // Write to storage/network/3rd party systems (demo) /////////////////////////////////////////////////////////////////// YourMethodToWriteToDatabase(patient); var bg = Console.BackgroundColor; Console.BackgroundColor = ConsoleColor.DarkGreen; Console.WriteLine("[ Read/Write data on network, storage, 3rd party systems etc. Data is always encrypted! ]" + Environment.NewLine); Console.BackgroundColor = bg; /////////////////////////////////////////////////////////////////// // Read from storage/network/3rd party systems (demo) /////////////////////////////////////////////////////////////////// var patient2 = YourMethodToReadFromDatabase(); Console.WriteLine($"Sealed Object: {JsonConvert.SerializeObject(patient2)}" + Environment.NewLine); /////////////////////////////////////////////////////////////////// // UNSEAL: Decrypt object here automagically /////////////////////////////////////////////////////////////////// Console.WriteLine("=> Unseal() performed on object" + Environment.NewLine); patient2.Unseal(); // <===== via extension method // Crypteron.CipherObject.Unseal(patient2); // <===== via explicit API (identical to the above) // patient.Name and patient.SSN are now decrypted // You can now use them in your app any way you like Console.WriteLine($"Clear Object : {JsonConvert.SerializeObject(patient2)}" + Environment.NewLine); Console.WriteLine(Environment.NewLine + "Additional documentation at http://crypteron.com/docs or contact [email protected] with questions"); Console.WriteLine(Environment.NewLine + "Press any key to exit ... "); Console.ReadLine(); }
private static Patient YourMethodToReadFromDatabase() { // Read as you would from any database, SQL, NoSQL or even message queues or REST endpoints // Simulating that here .. var dbRead = new Patient { Name = "Jack Reacher", SocialSecurityNumber = "777-77-7777" }; // Since we write sealed, we'd readback sealed too, simulate that return dbRead.Seal(); }