Esempio n. 1
0
    static void Main(string[] args)
    {
        // Set up
        var input      = "Perceived determine departure explained no forfeited";
        var enc        = new TFRSAEncryption();
        var publicKey  = "-----BEGIN PUBLIC KEY----- // SNIPPED // -----END PUBLIC KEY-----";
        var privateKey = "-----BEGIN PRIVATE KEY----- // SNIPPED // -----END PRIVATE KEY-----";
        // Encrypt it
        var encryptedWithPublic  = enc.RsaEncryptWithPublic(input, publicKey);
        var encryptedWithPrivate = enc.RsaEncryptWithPrivate(input, privateKey);
        // Decrypt
        var output1 = enc.RsaDecryptWithPrivate(encryptedWithPublic, privateKey);
        var output2 = enc.RsaDecryptWithPublic(encryptedWithPrivate, publicKey);

        Console.WriteLine(output1 == output2 && output2 == input);
        Console.Read();
    }
Esempio n. 2
0
        public static void Test()
        {
            // Set up
            string          input      = "Perceived determine departure explained no forfeited";
            TFRSAEncryption enc        = new TFRSAEncryption();
            string          publicKey  = "-----BEGIN PUBLIC KEY----- // Base64 string omitted // -----END PUBLIC KEY-----";
            string          privateKey = "-----BEGIN PRIVATE KEY----- // Base64 string omitted// -----END PRIVATE KEY-----";

            // Encrypt it
            string encryptedWithPublic  = enc.RsaEncryptWithPublic(input, publicKey);
            string encryptedWithPrivate = enc.RsaEncryptWithPrivate(input, privateKey);

            // Decrypt
            string output1 = enc.RsaDecryptWithPrivate(encryptedWithPublic, privateKey);
            string output2 = enc.RsaDecryptWithPublic(encryptedWithPrivate, publicKey);

            System.Console.WriteLine(output1 == output2 && output2 == input);
            System.Console.Read();
        }