Beispiel #1
0
        /// <summary>
        /// Encrtyp/decrypt a string
        /// </summary>
        /// <param name="secret">the string you wish to encrypt or decrypt</param>
        /// <param name="password">the password with which to encrypt the string</param>
        /// <returns></returns>
        private string Encrypt(string secret, string password)
        {
            int len = 0;
            int x   = 0;

            string temp = secret;

            len = password.Length;
            for (x = 1; x <= temp.Length; x++)
            {
                int ch = Strings.Asc(Strings.Mid(password, Convert.ToInt32((x % len) - len * Conversion.BoolToInt(((x % len) == 0))), 1));
                Strings.MidStmtStr(ref temp, x, 1, Strings.Chr(Strings.Asc(Strings.Mid(temp, x, 1)) ^ ch).ToString(System.Globalization.CultureInfo.InvariantCulture));
            }

            return(temp);
        }