Exemple #1
0
 //Create a RSAWrapper instance which will be used to encrypt and decrypt data.
 public RSAWrapper(string rsaName)
 {
     this.rsaName = rsaName;
     this.RSAalg  = HelperExtensions.StringToRSA(rsaName);
 }
Exemple #2
0
        //Check which properties have been initialized in this class instance and save them as a file.
        public void SaveFile()
        {
            streamWriter.WriteLine("---BEGIN OS2 CRYPTO DATA---");

            if (Description != null && Description != "")
            {
                streamWriter.WriteLine("Description:");
                streamWriter.WriteLine("\t" + Description + "\n");
            }

            if (FileName != null && FileName != "")
            {
                streamWriter.WriteLine("File Name:");
                streamWriter.WriteLine("\t" + FileName + "\n");
            }

            if (Method != null && Method != "")
            {
                streamWriter.WriteLine("Method:");
                streamWriter.WriteLine("\t" + Method + "\n");
            }

            if (Cipher != null && Cipher != "")
            {
                streamWriter.WriteLine("Cipher:");
                streamWriter.WriteLine("\t" + Cipher + "\n");
            }

            if (KeyLnegth != null && KeyLnegth != "")
            {
                streamWriter.WriteLine("Key lenegth:");
                streamWriter.WriteLine("\t" + KeyLnegth + "\n");
            }

            if (SecretKey != null && SecretKey != "")
            {
                streamWriter.WriteLine("Secret key:");
                HelperExtensions.PrintStringArray(streamWriter, HelperExtensions.SpliceText(SecretKey, 60));
            }

            if (InitializationVector != null && InitializationVector != "")
            {
                streamWriter.WriteLine("Initialization vector:");
                HelperExtensions.PrintStringArray(streamWriter, HelperExtensions.SpliceText(InitializationVector, 60));
            }

            if (Modulus != null && Modulus != "")
            {
                streamWriter.WriteLine("Modulus:");
                HelperExtensions.PrintStringArray(streamWriter, HelperExtensions.SpliceText(Modulus, 60));
            }

            if (PublicExponent != null && PublicExponent != "")
            {
                streamWriter.WriteLine("Public exponent:");
                HelperExtensions.PrintStringArray(streamWriter, HelperExtensions.SpliceText(PublicExponent, 60));
            }

            if (PrivateExponent != null && PrivateExponent != "")
            {
                streamWriter.WriteLine("Private exponent:");
                HelperExtensions.PrintStringArray(streamWriter, HelperExtensions.SpliceText(PrivateExponent, 60));
            }

            if (Signature != null && Signature != "")
            {
                streamWriter.WriteLine("Signature:");
                HelperExtensions.PrintStringArray(streamWriter, HelperExtensions.SpliceText(Signature, 60));
            }

            if (Data != null && Data != "")
            {
                streamWriter.WriteLine("Data:");
                HelperExtensions.PrintStringArray(streamWriter, HelperExtensions.SpliceText(Data, 60));
            }

            if (EnvelopeData != null && EnvelopeData != "")
            {
                streamWriter.WriteLine("Envelope data:");
                HelperExtensions.PrintStringArray(streamWriter, HelperExtensions.SpliceText(EnvelopeData, 60));
            }

            if (EnvelopeCryptKey != null && EnvelopeCryptKey != "")
            {
                streamWriter.WriteLine("Envelope crypt key:");
                HelperExtensions.PrintStringArray(streamWriter, HelperExtensions.SpliceText(EnvelopeCryptKey, 60));
            }

            if (RSAKey != null && RSAKey != "")
            {
                streamWriter.WriteLine("RSA key:");
                HelperExtensions.PrintStringArray(streamWriter, HelperExtensions.SpliceText(RSAKey, 60));
            }

            streamWriter.WriteLine("---END OS2 CRYPTO DATA---");
            streamWriter.Close();
        }