Пример #1
0
        public static string decryptString(string cipherText, string passPhrase)
        {
            string decryptedString = "";

            string initVector = @"6D5F23DFC259C113";                // must be 16 bytes
            //Create salt value, value between 4 and 8 bytes long
            //Using the username as passphhrase
            RijndaelEnhanced rijndaelKey = new RijndaelEnhanced(passPhrase, initVector);


            //Decrypt the Password
            decryptedString = rijndaelKey.Decrypt(cipherText);

            //rijndaelKey.Decrypt(PassPhrase)  -->  SecureString
            return(decryptedString);
        }
Пример #2
0
        //Base Code Source = http://www.obviex.com/samples/encryptionwithsalt.aspx;
        //Changes have been made to the code


        public static string encryptString(string toEncrypt, string password)
        {
            string EncryptedString;

            string plainText  = toEncrypt;
            string passPhrase = password;                   // can be any string
            string initVector = @"6D5F23DFC259C113";        // must be 16 bytes

            //Create salt value, value between 4 and 8 bytes long
            //Using the password as passphhrase
            RijndaelEnhanced rijndaelKey = new RijndaelEnhanced(passPhrase, initVector);

            //Encrypt the Password
            EncryptedString = rijndaelKey.Encrypt(plainText);

            //Decrypt the Password
            //plainText = rijndaelKey.Decrypt(cipherText);



            return(EncryptedString);
        }