troubleshooting Question

c# Basic Encyption/Decryption

Avatar of MooksUK
MooksUK asked on
C#
7 Comments1 Solution389 ViewsLast Modified:
Hi,

I have created a function based upon something from VB6 which allows me to encrypt/decrypt some basic information. The encryption works fine but when I attempt to use the same function to decrypt not all characters are converted correctly.

I can not change the encryption method from this Xor method as the data which is encrypted is used by many programs written in different languages. Hence I have adopted it from VB6.

Any ideas why it would encrypt OK but have problems decrypting?? Any help greatly appreciated.

        public static string EncryptPW(string p)
        {
           
            //Encrypt password
            string strResult = "";
            char testChar;
            for (int i = 0; i < p.Length; i++)
            {
                testChar = Convert.ToChar(p.Substring(i, 1));
                strResult += (char)(testChar ^ 255);
            }

            return strResult;
        }
ASKER CERTIFIED SOLUTION
Chuck Yetter

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros