当前位置: 首页>>代码示例>>C#>>正文


C# Patient.Seal方法代码示例

本文整理汇总了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();
        }
开发者ID:crypteron,项目名称:crypteron-sample-apps,代码行数:53,代码来源:Program.cs

示例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();
        }
开发者ID:crypteron,项目名称:crypteron-sample-apps,代码行数:13,代码来源:Program.cs


注:本文中的Patient.Seal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。