本文整理汇总了C#中Patient.Seal方法的典型用法代码示例。如果您正苦于以下问题:C# Patient.Seal方法的具体用法?C# Patient.Seal怎么用?C# Patient.Seal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Patient
的用法示例。
在下文中一共展示了Patient.Seal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
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();
}
示例2: YourMethodToReadFromDatabase
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();
}