我有个解密函数是用 web里的js写的function MM_DeImages(ImageName)
{
var strSrc = ImageName;
strSrc = strSrc.substring(10);
strSrc = strSrc.substring(0,strSrc.length-5);
var strTemp = "";
var lngIndex;
for(lngIndex=1;lngIndex<=parseInt(strSrc.length/6);lngIndex+=2){
if(Math.abs(parseInt(strSrc.substring(lngIndex * 6,lngIndex * 6 + 6)) - 153874) < 32768){
strTemp = strTemp + String.fromCharCode(parseInt(strSrc.substring(lngIndex * 6,lngIndex * 6 + 6)) - 153874);
}
}
return strTemp;
}谁能给我翻译成c#呀?能力有限制,翻译不了
{
var strSrc = ImageName;
strSrc = strSrc.substring(10);
strSrc = strSrc.substring(0,strSrc.length-5);
var strTemp = "";
var lngIndex;
for(lngIndex=1;lngIndex<=parseInt(strSrc.length/6);lngIndex+=2){
if(Math.abs(parseInt(strSrc.substring(lngIndex * 6,lngIndex * 6 + 6)) - 153874) < 32768){
strTemp = strTemp + String.fromCharCode(parseInt(strSrc.substring(lngIndex * 6,lngIndex * 6 + 6)) - 153874);
}
}
return strTemp;
}谁能给我翻译成c#呀?能力有限制,翻译不了
private void asfd()
{
string strSrc = ImageName;
strSrc = strSrc.Substring(10);
strSrc = strSrc.Substring(0, strSrc.Length - 5);
string strTemp = "";
int lngIndex=1;
for (lngIndex = 1; lngIndex <= int.Parse(strSrc.length / 6); lngIndex += 2)
{
if (Math.abs(int.Parse(strSrc.Substring(lngIndex * 6, lngIndex * 6 + 6)) - 153874) < 32768)
{
strTemp = strTemp + (char)(int.Parse(strSrc.substring(lngIndex * 6, lngIndex * 6 + 6)) - 153874);
}
}
return strTemp;
}
{
string strSrc = ImageName; //此处若用.NET3.5,则可以保留var关键字,以下同
strSrc = strSrc.SubString(10);
strSrc = strSrc.SubString(0, strSrc.Length - 5);
string strTemp = "";
int lngIndex;
for(lngIndex = 1; lngIndex <= (int)strSrc.length/6; lngIndex+=2)
{
if(Math.Abs(int.Parse(strSrc.SubString(lngIndex * 6,lngIndex * 6 + 6)) - 153874) < 32768)
{
strTemp = strTemp + Char.ConvertFromUtf32(int.Parse(strSrc.SubString(lngIndex * 6,lngIndex * 6 + 6)) - 153874)).ToString();
}
}
return strTemp;
}
{
string strSrc = ImageName;
strSrc = strSrc.Substring(10);
strSrc = strSrc.Substring(0, strSrc.Length - 5);
string strTemp = "";
int lngIndex=1;
for (lngIndex = 1; lngIndex <= int.Parse(strSrc.length / 6); lngIndex += 2)
{
if (Math.abs(int.Parse(strSrc.Substring(lngIndex * 6, lngIndex * 6 + 6)) - 153874) < 32768)
{ int ias=int.Parse(strSrc.substring(lngIndex * 6, lngIndex * 6 + 6) - 153874
strTemp = strTemp + ias.Tostring();
}
}
return strTemp;
}
private string MM_DeImages(string ImageName)
{
string strSrc = ImageName;
strSrc = strSrc.Substring(10);
strSrc = strSrc.Substring(0, strSrc.Length - 5);
string strTemp = "";
Int64 lngIndex = 1;
for (lngIndex = 1; lngIndex <= Convert.ToInt64(strSrc.Length / 6); lngIndex += 2)
{
if (Math.Abs(Int64.Parse(strSrc.Substring((int)lngIndex * 6, (int)lngIndex * 6 + 6)) - 153874) < 32768)
{
strTemp = strTemp + (char)(Int64.Parse(strSrc.Substring((int)lngIndex * 6, (int)lngIndex * 6 + 6)) - 153874);
}
}
return strTemp;
}
{
lngIndex -= int.MaxValue / 6;
strSrc.Remove(0,int.MaxValue / 6);
}
{
string strSrc = ImageName;
strSrc = strSrc.Substring(10);
strSrc = strSrc.Substring(0, strSrc.Length - 5);
string strTemp = "";
int lngIndex = 1;
for (lngIndex = 1; lngIndex <= Convert.ToInt64(strSrc.Length / 6); lngIndex += 2)
{
//加入以下部分
while((long)lngIndex * (long)6 > int.MaxValue)
{
lngIndex -= int.MaxValue / 6;
strSrc.Remove(0,int.MaxValue / 6);
} if (Math.Abs(Int64.Parse(strSrc.Substring(lngIndex * 6, lngIndex * 6 + 6)) - 153874) < 32768)
{
strTemp = strTemp + (char)(Int64.Parse(strSrc.Substring(lngIndex * 6, lngIndex * 6 + 6)) - 153874);
}
}
return strTemp;
}
要转换的字符串 超出了int的范围了.......int装不了用这个类型呢 decimal