private string EnCrypt(string strCryptThis)
{
string strChar, iKeyChar, iStringChar, g_Key;
int I;
g_Key="welcome to powerise and welcome to powerdweb2000 thanks!".Substring(1,strCryptThis.Length)
string strstrEncrypted="";
for (I = 1;I<strCryptThis.Length;I++)
{
iKeyChar = g_Key.Substring(I,1));
iStringChar = strCryptThis.Substring(I,1);
char ck=iKeyChar.ToCharArray()[0];
char cs=iStringChar.ToCharArray()[0];
char iCryptChar = ck ^cs;
strEncrypted = strEncrypted + iCarptChar.ToString();
}
return strEncrypted;
}
大概是这样,可能有一些语法错误,自己该该吧
{
string strChar, iKeyChar, iStringChar, g_Key;
int I;
g_Key="welcome to powerise and welcome to powerdweb2000 thanks!".Substring(1,strCryptThis.Length)
string strstrEncrypted="";
for (I = 1;I<strCryptThis.Length;I++)
{
iKeyChar = g_Key.Substring(I,1));
iStringChar = strCryptThis.Substring(I,1);
char ck=iKeyChar.ToCharArray()[0];
char cs=iStringChar.ToCharArray()[0];
char iCryptChar = ck ^cs;
strEncrypted = strEncrypted + iCarptChar.ToString();
}
return strEncrypted;
}
大概是这样,可能有一些语法错误,自己该该吧
把string strstrEncrypted="";
该为string strEncrypted="";
char iCryptChar = ck ^cs;
改为
char iCryptChar =(char)(ck ^cs);
{
string strChar, iKeyChar, iStringChar, g_Key;
int I;
g_Key="welcome to powerise and welcome to powerdweb2000 thanks!".Substring(1,strCryptThis.Length)
string string strEncrypted="";
for (I = 1;I<strCryptThis.Length;I++)
{
iKeyChar = g_Key.Substring(I,1));
iStringChar = strCryptThis.Substring(I,1);
char ck=iKeyChar.ToCharArray()[0];
char cs=iStringChar.ToCharArray()[0];
char iCryptChar =(char)(ck ^cs);
strEncrypted = strEncrypted + iCarptChar.ToString();
}
return strEncrypted;
}
private string EnCrypt(string PassStr)
{
string ReturnKey = "";
int iKeyChar,iStringChar;
int iCryptChar;
string Key = "welcome to powerise and welcome to powerdweb2000 thanks!";
string g_Key = Key.Substring(1,PassStr.Length);
for(int i=0; i <PassStr.Length ; i++)
{
iKeyChar = this.asc(Convert.ToChar(g_Key.Substring(i,1)));
iStringChar = this.asc(Convert.ToChar(PassStr.Substring(i,1)));
iCryptChar = iKeyChar ^ iStringChar;
ReturnKey = ReturnKey + Convert.ToChar(iCryptChar);
}
return ReturnKey;
}
private int asc(char ch)
{
byte[] b=System.Text.Encoding.Default.GetBytes(ch.ToString().ToCharArray());
int result=b[0];
if(b.Length==2)result=(result<<8)+b[1];
return result;
}
{
string g_Key;
int I;
g_Key = "welcome to powerise and welcome to powerdweb2000 thanks!".Substring(0/*1==>0*/,strCryptThis.Length);
string sRe = "";
for (I = 0/*1==>0*/;I<strCryptThis.Length;I++)
{
char ck=g_Key.ToCharArray()[I];
char cs=strCryptThis.ToCharArray()[I];
char iCryptChar = (char)(ck ^cs);
sRe +=iCryptChar.ToString();
}
return sRe;
}