Exemplo n.º 1
0
        void ManualKeyData()
        {
            byte[] modulus   = Encoding.ASCII.GetBytes(Modulus);
            byte[] exponent  = Encoding.ASCII.GetBytes(Exponent);
            byte[] toEncrypt = Encoding.ASCII.GetBytes(PlainText);

            rsaxml = new RSAXML(modulus, exponent);

            byte[] encrypted = rsaxml.Encrypt(toEncrypt);

            CipherBytes = Convert.ToBase64String(encrypted);

            EncryptButtonText = "Success!";
        }
Exemplo n.º 2
0
        void AutomaticKeyData()
        {
            rsaxml = new RSAXML();
            Printer printer = new Printer();

            if (string.IsNullOrEmpty(PlainText))
            {
                PlainText = "I BE TEXT";
            }

            byte[] toEncrypt = Encoding.ASCII.GetBytes(PlainText);

            byte[] encrypted = rsaxml.Encrypt(toEncrypt);

            CipherBytes = Convert.ToBase64String(encrypted);

            Modulus  = BuildHexString(rsaxml.Modulus);
            Exponent = BuildHexString(rsaxml.Exponent);

            printer.SaveToFile(CipherBytes, fileName);

            EncryptButtonText = "Success!";
        }