Private Const HARD_KEY = &H37
Private Function Encrypt(sValue, sKey)
Dim intLen
Dim sTempValue
Dim sTempKey
Dim sRValue
Dim sChar
sChar = 0
sTempValue = sValue
sTempKey = Trim(sKey)
sRValue = ""
Dim intX, intY
For intX = 1 To Len(sTempValue)
sChar = CInt(Asc(Mid(sTempValue, intX, 1)))
For intY = 1 To Len(sTempKey)
sChar = sChar Xor CInt(Asc(Mid(sTempKey, intY, 1))) Xor HARD_KEY
Next
sRValue = sRValue & Trim(Chr(sChar))
Next
Encrypt = sRValue
End Function有没有懂C#的高手帮忙把上面的ASP代码转成c# asp.net的代码 下面是我转的 觉得不对,有没有高手能帮忙找错的int HARD_KEY = Convert.ToInt32("37", 16);
private string Encrypt(string sValue, string sKey)
{
string sTempValue = sValue;
string sTempKey = sKey.Trim();
string sRValue = "";
int sChar = 0;
for(int x = 1;x < sTempValue.Length;x++ )
{
sChar = Microsoft.VisualBasic.Strings.Asc(sTempValue.Substring(x, 1));
for(int y = 1;y <sTempKey.Length;y ++)
{
int asc = Microsoft.VisualBasic.Strings.Asc(sTempValue.Substring(y, 1));
sChar = asc | HARD_KEY;
}
sRValue = sRValue + Microsoft.VisualBasic.Strings.Chr(sChar).ToString();
}
listBox3.Items.Add(sRValue);
return sRValue;
}
Private Function Encrypt(sValue, sKey)
Dim intLen
Dim sTempValue
Dim sTempKey
Dim sRValue
Dim sChar
sChar = 0
sTempValue = sValue
sTempKey = Trim(sKey)
sRValue = ""
Dim intX, intY
For intX = 1 To Len(sTempValue)
sChar = CInt(Asc(Mid(sTempValue, intX, 1)))
For intY = 1 To Len(sTempKey)
sChar = sChar Xor CInt(Asc(Mid(sTempKey, intY, 1))) Xor HARD_KEY
Next
sRValue = sRValue & Trim(Chr(sChar))
Next
Encrypt = sRValue
End Function有没有懂C#的高手帮忙把上面的ASP代码转成c# asp.net的代码 下面是我转的 觉得不对,有没有高手能帮忙找错的int HARD_KEY = Convert.ToInt32("37", 16);
private string Encrypt(string sValue, string sKey)
{
string sTempValue = sValue;
string sTempKey = sKey.Trim();
string sRValue = "";
int sChar = 0;
for(int x = 1;x < sTempValue.Length;x++ )
{
sChar = Microsoft.VisualBasic.Strings.Asc(sTempValue.Substring(x, 1));
for(int y = 1;y <sTempKey.Length;y ++)
{
int asc = Microsoft.VisualBasic.Strings.Asc(sTempValue.Substring(y, 1));
sChar = asc | HARD_KEY;
}
sRValue = sRValue + Microsoft.VisualBasic.Strings.Chr(sChar).ToString();
}
listBox3.Items.Add(sRValue);
return sRValue;
}
int HARD_KEY = Convert.ToInt32("37", 16);
private string Encrypt(string sValue, string sKey)
{
string sTempValue = sValue;
string sTempKey = sKey.Trim();
string sRValue = "";
int sChar = 0;
for (int x = 1; x < sTempValue.Length; x++)
{
sChar = Convert.ToInt32(sTempValue.Substring(x, 1));
for (int y = 1; y < sTempKey.Length; y++)
{
int asc = Convert.ToInt32(sTempValue.Substring(y, 1));
sChar = asc | HARD_KEY;
}
sRValue = sRValue + Convert.ToChar(sChar).ToString();
}
listBox3.Items.Add(sRValue);
return sRValue;
}
{
string sTempValue = sValue;
string sTempKey = sKey.Trim();
string sRValue = "";
int sChar = 0;
for (int x = 1; x <= sTempValue.Length; x++)
{
sChar = Microsoft.VisualBasic.Strings.Asc(sTempValue.Substring(x - 1, 1));
for (int y = 1; y <= sTempKey.Length; y++)
{
int asc = Microsoft.VisualBasic.Strings.Asc(sTempKey.Substring(y - 1, 1));
sChar = sChar ^ asc ^ HARD_KEY;
listBox3.Items.Add(sRValue + "; " + asc + "; " + sChar.ToString());
}
sRValue = sRValue + Microsoft.VisualBasic.Strings.Chr(sChar).ToString(); } return sRValue;
}
可还是不正确
private string Encrypt(string sValue, string sKey)
{
string sTempValue = sValue;
string sTempKey = sKey.Trim();
string sRValue = "";
int sChar = 0;
for (int x = 0; x < sTempValue.Length; x++)
{
sChar = Microsoft.VisualBasic.Strings.Asc(sTempValue.Substring(x , 1));
for (int y = 0; y < sTempKey.Length; y++)
{
int asc = Microsoft.VisualBasic.Strings.Asc(sTempKey.Substring(y, 1));
sChar = sChar ^ asc ^ HARD_KEY;
}
sRValue = sRValue + Microsoft.VisualBasic.Strings.Chr(sChar).ToString();
}
return sRValue;
}
Private Function Encrypt(ByRef sValue As Object, ByRef sKey As Object) As Object
Dim intLen As Object
Dim sTempValue As Object
Dim sTempKey As Object
Dim sRValue As Object
Dim sChar As Object
'UPGRADE_WARNING: 未能解析对象 sChar 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"”
sChar = 0
'UPGRADE_WARNING: 未能解析对象 sValue 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"”
'UPGRADE_WARNING: 未能解析对象 sTempValue 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"”
sTempValue = sValue
'UPGRADE_WARNING: 未能解析对象 sKey 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"”
'UPGRADE_WARNING: 未能解析对象 sTempKey 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"”
sTempKey = Trim(sKey)
'UPGRADE_WARNING: 未能解析对象 sRValue 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"”
sRValue = ""
Dim intX, intY As Object
For intX = 1 To Len(sTempValue)
'UPGRADE_WARNING: 未能解析对象 intX 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"”
'UPGRADE_WARNING: 未能解析对象 sTempValue 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"”
'UPGRADE_WARNING: 未能解析对象 sChar 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"”
sChar = CShort(Asc(Mid(sTempValue, intX, 1)))
For intY = 1 To Len(sTempKey)
'UPGRADE_WARNING: 未能解析对象 intY 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"”
'UPGRADE_WARNING: 未能解析对象 sTempKey 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"”
'UPGRADE_WARNING: 未能解析对象 sChar 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"”
sChar = sChar Xor CShort(Asc(Mid(sTempKey, intY, 1))) Xor HARD_KEY
Next
'UPGRADE_WARNING: 未能解析对象 sChar 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"”
'UPGRADE_WARNING: 未能解析对象 sRValue 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"”
sRValue = sRValue & Trim(Chr(sChar))
Next
'UPGRADE_WARNING: 未能解析对象 sRValue 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"”
'UPGRADE_WARNING: 未能解析对象 Encrypt 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"”
Encrypt = sRValue
End Function
{
//Dim intLen string sRValue = string.Empty;
char sChar;
//sChar = 0
string sTempValue = sValue;
string sTempKey = sKey.Trim(); foreach (char x in sTempValue)
{
sChar = x;
foreach (char y in sTempKey)
{
int asc = Convert.ToInt32(y);
sChar = (char)asc | HARD_KEY;
}
sRValue = sRValue + sChar.ToString();
}
listBox3.Items.Add(sRValue);
return sRValue;
}