コード例 #1
0
        /// <summary>
        /// The Encryption method.
        /// </summary>
        /// <param name="plainText">The string to encrypt.</param>
        /// <param name="password">The password.</param>
        /// <returns>The encrypted string.</returns>
        public ReturnStruct EncryptString(string plainText, string partPassword)
        {
            List <int> ril = new List <int>();
            Random     r   = new Random();

            for (int i = 0; i < 6; i++)
            {
                ril.Add(r.Next(0, 10));
            }

            List <string> sl = NumberConverter.IntCollectionToStringList(ril);

            // 3DES
            DESProvider des  = DESProvider.Instance;
            string      des1 = des.EncryptString(plainText, partPassword + sl[0]);
            string      des2 = des.EncryptString(des1, partPassword + sl[1]);
            string      des3 = des.EncryptString(des2, partPassword + sl[2]);

            // 3AES
            AESProvider aes  = AESProvider.Instance;
            string      aes1 = aes.EncryptString(des3, partPassword + sl[3]);
            string      aes2 = aes.EncryptString(aes1, partPassword + sl[4]);
            string      aes3 = aes.EncryptString(aes2, partPassword + sl[5]);

            ReturnStruct rs = new ReturnStruct();

            rs.Result     = aes3;
            rs.RandomKeys = ril.ToArray();

            return(rs);

            // Use Casts: aes(aes(aes(des(des(des($content))))));
        }