Advertisement

05.03.2008 at 06:21PM PDT, ID: 23374409
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

What's the official name of this encryption algorithm?

Asked by newbieweb in Microsoft Visual C#.Net, Encryption for Network Security, Algorithms

I was provided this code on EE and it has worked well for me.  But I am curious of the name of the algorithm.

Also, what basic technology is it based on?

How hard would it be for someone to break it?  How does it compare to PGP grade encryption?


thanks,
newbieweb

    class EncryptIt
    {
        // Encrypt a string into a string using a password
        //    Uses Encrypt(byte[], byte[], byte[])
        public static string Encrypt(string clearText, string Password)
        {
            byte[] clearBytes =
              System.Text.Encoding.Unicode.GetBytes(clearText);
            PasswordDeriveBytes pdb = new PasswordDeriveBytes(Password, System.Text.ASCIIEncoding.UTF8.GetBytes(salterGUID));
            byte[] encryptedData = Encrypt(clearBytes,
                     pdb.GetBytes(32), pdb.GetBytes(16));

            return Convert.ToBase64String(encryptedData);

        }

        // Decrypt a string into a string using a password
        //    Uses Decrypt(byte[], byte[], byte[])
        public static string Decrypt(string cipherText, string Password)
        {
            byte[] cipherBytes = Convert.FromBase64String(cipherText);

            PasswordDeriveBytes pdb = new PasswordDeriveBytes(Password, System.Text.ASCIIEncoding.UTF8.GetBytes(salterGUID));


            byte[] decryptedData = Decrypt(cipherBytes,
                pdb.GetBytes(32), pdb.GetBytes(16));

            return System.Text.Encoding.Unicode.GetString(decryptedData);
        }

        #region internal methods

        internal static string salterGUID = "{7DBA82CF-DEB2-4c6f-AF6E-FD9C02B0E1EA}";



        // Encrypt a byte array into a byte array using a key and an IV
        internal static byte[] Encrypt(byte[] clearData, byte[] Key, byte[] IV)
        {
            // Create a MemoryStream to accept the encrypted bytes
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            Rijndael alg = Rijndael.Create();

            alg.Key = Key;
            alg.IV = IV;
            CryptoStream cs = new CryptoStream(ms,
               alg.CreateEncryptor(), CryptoStreamMode.Write);

            // Write the data and make it do the encryption
            cs.Write(clearData, 0, clearData.Length);

            cs.Close();
            byte[] encryptedData = ms.ToArray();

            return encryptedData;
        }
        // Encrypt bytes into bytes using a password
        //    Uses Encrypt(byte[], byte[], byte[])

        internal static byte[] Encrypt(byte[] clearData, string Password)
        {
            PasswordDeriveBytes pdb = new PasswordDeriveBytes(Password, System.Text.ASCIIEncoding.UTF8.GetBytes(salterGUID));
            return Encrypt(clearData, pdb.GetBytes(32), pdb.GetBytes(16));
        }


        // Decrypt a byte array into a byte array using a key and an IV
        internal static byte[] Decrypt(byte[] cipherData,
                                    byte[] Key, byte[] IV)
        {
            System.IO.MemoryStream ms = new System.IO.MemoryStream();

            Rijndael alg = Rijndael.Create();
            alg.Key = Key;
            alg.IV = IV;

            CryptoStream cs = new CryptoStream(ms,
                alg.CreateDecryptor(), CryptoStreamMode.Write);

            cs.Write(cipherData, 0, cipherData.Length);
            cs.Close();

            byte[] decryptedData = ms.ToArray();

            return decryptedData;
        }
        #endregion
    }
Start Free Trial
[+][-]05.03.2008 at 06:29PM PDT, ID: 21494278

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual C#.Net, Encryption for Network Security, Algorithms
Sign Up Now!
Solution Provided By: DarkoLord
Participating Experts: 4
Solution Grade: A
 
 
[+][-]05.03.2008 at 06:32PM PDT, ID: 21494280

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05.03.2008 at 06:37PM PDT, ID: 21494290

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.03.2008 at 06:59PM PDT, ID: 21494349

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05.04.2008 at 12:49PM PDT, ID: 21496736

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628