Beispiel #1
0
        private static string EncryptEmail(string email)
        {
            StringBuilder result = new StringBuilder();

            int atIndex = email.IndexOf('@');

            string beforeAt = email.Substring(0, atIndex);
            string afterAt  = email.Substring(atIndex + 1);

            string[] partsBeforeAt = beforeAt.Split('.');
            string[] partsAfterAt  = afterAt.Split('.');

            for (int i = 0; i < partsBeforeAt.Length; i++)
            {
                result.Append(Cryptographing.Encrypt(partsBeforeAt[i]));
                if (i < partsBeforeAt.Length - 1)
                {
                    result.Append('.');
                }
            }

            result.Append('@');

            for (int i = 0; i < partsAfterAt.Length; i++)
            {
                result.Append(Cryptographing.Encrypt(partsAfterAt[i]));
                if (i < partsAfterAt.Length - 1)
                {
                    result.Append('.');
                }
            }

            return(result.ToString());
        }
Beispiel #2
0
        public static string DecryptEmail(string decryptedEmail)
        {
            StringBuilder result = new StringBuilder();

            int atIndex = decryptedEmail.IndexOf('@');

            string beforeAt = decryptedEmail.Substring(0, atIndex);
            string afterAt  = decryptedEmail.Substring(atIndex + 1);

            string[] partsBeforeAt = beforeAt.Split('.');
            string[] partsAfterAt  = afterAt.Split('.');

            for (int i = 0; i < partsBeforeAt.Length; i++)
            {
                partsBeforeAt[i] = partsBeforeAt[i].Replace(' ', '+');
                result.Append(Cryptographing.Decrypt(partsBeforeAt[i]));
                if (i < partsBeforeAt.Length - 1)
                {
                    result.Append('.');
                }
            }

            result.Append('@');

            for (int i = 0; i < partsAfterAt.Length; i++)
            {
                partsAfterAt[i] = partsAfterAt[i].Replace(' ', '+');
                result.Append(Cryptographing.Decrypt(partsAfterAt[i]));
                if (i < partsAfterAt.Length - 1)
                {
                    result.Append('.');
                }
            }

            return(result.ToString());
        }