using System;
using System.Text;
namespace SetPassword
{
/// <summary>
/// .net 密码加密
/// </summary>
class CbsPassword
{
[STAThread]
static void Main(string[] args)
{
string pwd = "hello你好啊";
Console.WriteLine("原字符串:" + pwd + "," + pwd.Length.ToString());
Console.WriteLine("字符串加密:" + StringEncoding(pwd) + "," + StringEncoding(pwd).Length.ToString());
Console.WriteLine("字符串解密:" + StringDecoding(StringEncoding(pwd)) + "," + StringDecoding(StringEncoding(pwd)).Length.ToString());
Console.ReadLine();
}
static string StringEncoding(string pwd)
{
char [] arrChar = pwd.ToCharArray();
string strChar = "";
for(int i = 0;i < arrChar.Length;i++)
{
arrChar[i] = Convert.ToChar(arrChar[i]+1);
strChar = strChar + arrChar[i].ToString();
}
return strChar;
}
static string StringDecoding(string pwd)
{
char [] arrChar = pwd.ToCharArray();
string strChar = "";
for(int i = 0;i < arrChar.Length;i++)
{
arrChar[i] = Convert.ToChar(arrChar[i]-1);
strChar = strChar + arrChar[i].ToString();
}
return strChar;
}
}
}