C#代码
- namespace Devgg.Common
- {
- using System;
- public class EncryptString
- {
- private const Char XOR_STRING = ‘天啦’;
- public static String Encrypt(String sourceString)
- {
- Char[] sourceArray = sourceString.ToCharArray();
- System.Text.StringBuilder temp = new System.Text.StringBuilder();
- for (Int32 i = 0; i < sourceArray.Length; i++)
- {
- sourceArray[i] = (Char)(sourceArray[i] ^ XOR_STRING);
- temp.Append(sourceArray[i].ToString());
- }
- return temp.ToString();
- }
- public static String Dencrypt(String ciphertext)
- {
- Char[] ciphertextArray = ciphertext.ToCharArray();
- System.Text.StringBuilder temp = new System.Text.StringBuilder();
- for (Int32 i = 0; i < ciphertextArray.Length; i++)
- {
- ciphertextArray[i] = (Char)(ciphertextArray[i] ^ XOR_STRING);
- temp.Append(ciphertextArray[i].ToString());
- }
- return temp.ToString();
- }
- }
- }