示例#1
0
        static void Main(string[] args)
        {
            //load configuration data
            RemotingConfiguration.Configure(@"TestConsole.exe.config");

            //(1). Test the data encryption/decryption using SAF.Cryptography
            //	(a) test the symmatric cryptography
            string original  = "This is a test!";
            string encrypted = Encryption.Encrypt(original, "Profile1");

            Console.WriteLine("Encrypted data is : " + encrypted);
            string decrypted = Decryption.Decrypt(encrypted, "Profile1");

            Console.WriteLine("Decrypted data is : " + decrypted);

            //	(b) test the asymmatric cryptography
            byte[] key;
            byte[] iv;
            byte[] signature;
            encrypted = Encryption.Encrypt(original, "Profile2", out key, out iv, out signature);
            Console.WriteLine("Encrypted data is : " + encrypted);
            decrypted = Decryption.Decrypt(encrypted, "Profile3", key, iv, signature);
            Console.WriteLine("Decrypted data is : " + decrypted);


            //(2). Test the secure remoting call via CryptoRemotingClient(Server)Sink.
            //Please refer to configuration file for profile information used for remoting calls.
            //creating the remoting object
            SampleBusiness sb = new SampleBusiness();

            //invoking the secure remoting call.
            Console.WriteLine(sb.SayHelloWorld());
            Console.WriteLine("press enter to exit");
            Console.ReadLine();
        }