另外问下代码中if(((sc^kc)==39)||((sc^kc)==92)||((sc^kc)<32)||((sc^kc)>126)) 中的^是什么意思?
function m(s){
var c,n,z,i;
z="";
i=0;
while(i<s.length){
c=s.charAt(i);
if("u"==c){
c="%"+c;
c+=s.charAt(i+1);
c+=s.charAt(i+2);
c+=s.charAt(i+3);
c+=s.charAt(i+4);
n=5;
}else {
c="%"+c;
c+=s.charAt(i+1);
n=2;
}
z+=c;
i=i+n;
}
return z;
function d(os){
var key="DecryptIT";
var ds;
ds="";
var kp,sp,s,kc,sc;
kp=0;
sp=0;
while(sp<os.length){
sc=os.charCodeAt(sp);
kc=key.charCodeAt(kp);
if(((sc^kc)==39)||((sc^kc)==92)||((sc^kc)<32)||((sc^kc)>126)){
s=String.fromCharCode(sc);
}else {
s=String.fromCharCode((sc^kc));
}
ds+=s;
kp++;
sp++;
if(kp>=key.length){
kp=0;
}
}
return ds;
}
6 个解决方案
#1
异或
是一种逻辑运算符。用的比较少。
具体用法请百度一下吧。类似&(且)!(非)|(或) ^(异或)
是一种逻辑运算符。用的比较少。
具体用法请百度一下吧。类似&(且)!(非)|(或) ^(异或)
#2
Function m(s)
Dim c,n,z,i
z = ""
i = 1
Do While i<=Len(s)
c = Mid(s, i, 1)
If "u" = c Then
c = "%" & c
c = c & Mid(s, i+1, 1)
c = c & Mid(s, i+2, 1)
c = c & Mid(s, i+3, 1)
c = c & Mid(s, i+4, 1)
n = 5
Else
c = "%" & c
c = c & Mid(s, i+1, 1)
n = 2
End If
z = z & c
i = i + n
Loop
m = z
End Function
Function d(os)
Dim key : key = "DecryptIT"
Dim ds
ds = ""
Dim kp,sp,s,kc,sc
kp = 1
sp = 1
Do While sp <= Len(os)
sc = Asc(Mid(os, sp, 1))
kc = Asc(Mid(key, kp, 1))
If (sc XOR kc)=39 Or (sc XOR kc)= 92 Or (sc XOR kc)<32 Or (sc XOR kc)>126 Then
s = Chr(sc)
Else
s = Chr(sc XOR kc)
End If
ds = ds & s
kp = kp + 1
sp = sp + 1
If kp >= Len(key) Then
kp = 1
End If
Loop
d = ds
End Function
#3
+1
#4
多谢hookee老大,不过这个函数有点问题,vbs跟js的结果只有前8位是对的,后边都不同。
请看例子:
请看例子:
function d(os){
var key="DecryptIT";
var ds;
ds="";
var kp,sp,s,kc,sc;
kp=0;
sp=0;
while(sp<os.length){
sc=os.charCodeAt(sp);
kc=key.charCodeAt(kp);
if(((sc^kc)==39)||((sc^kc)==92)||((sc^kc)<32)||((sc^kc)>126)){
s=String.fromCharCode(sc);
}else {
s=String.fromCharCode((sc^kc));
}
ds+=s;
kp++;
sp++;
if(kp>=key.length){
kp=0;
}
}
return ds;
}
alert(d("w&UJNDBDbCV&@IBD{dvUP1OHB|buSWA<BD{dw&U6OEC}"));
Function d(os)
Dim key : key = "DecryptIT"
Dim ds
ds = ""
Dim kp,sp,s,kc,sc
kp = 1
sp = 1
Do While sp <= Len(os)
sc = Asc(Mid(os, sp, 1))
kc = Asc(Mid(key, kp, 1))
If (sc XOR kc)=39 Or (sc XOR kc)= 92 Or (sc XOR kc)<32 Or (sc XOR kc)>126 Then
s = Chr(sc)
Else
s = Chr(sc XOR kc)
End If
ds = ds & s
kp = kp + 1
sp = sp + 1
If kp >= Len(key) Then
kp = 1
End If
Loop
d = ds
End Function
msgbox(d("w&UJNDBDbCV&@IBD{dvUP1OHB|buSWA<BD{dw&U6OEC}"))
#5
Function d(os)
Dim key : key = "DecryptIT"
Dim ds
ds = ""
Dim kp,sp,s,kc,sc
kp = 1
sp = 1
Do While sp <= Len(os)
sc = Asc(Mid(os, sp, 1))
kc = Asc(Mid(key, kp, 1))
If (sc XOR kc)=39 Or (sc XOR kc)= 92 Or (sc XOR kc)<32 Or (sc XOR kc)>126 Then
s = Chr(sc)
Else
s = Chr(sc XOR kc)
End If
ds = ds & s
kp = kp + 1
sp = sp + 1
If kp > Len(key) Then
kp = 1
End If
Loop
d = ds
End Function
#6
漂亮!多谢hookee兄,您的无私奉献帮助让我解决了难题,相信也有很多人得到您的帮助,致敬!
#1
异或
是一种逻辑运算符。用的比较少。
具体用法请百度一下吧。类似&(且)!(非)|(或) ^(异或)
是一种逻辑运算符。用的比较少。
具体用法请百度一下吧。类似&(且)!(非)|(或) ^(异或)
#2
Function m(s)
Dim c,n,z,i
z = ""
i = 1
Do While i<=Len(s)
c = Mid(s, i, 1)
If "u" = c Then
c = "%" & c
c = c & Mid(s, i+1, 1)
c = c & Mid(s, i+2, 1)
c = c & Mid(s, i+3, 1)
c = c & Mid(s, i+4, 1)
n = 5
Else
c = "%" & c
c = c & Mid(s, i+1, 1)
n = 2
End If
z = z & c
i = i + n
Loop
m = z
End Function
Function d(os)
Dim key : key = "DecryptIT"
Dim ds
ds = ""
Dim kp,sp,s,kc,sc
kp = 1
sp = 1
Do While sp <= Len(os)
sc = Asc(Mid(os, sp, 1))
kc = Asc(Mid(key, kp, 1))
If (sc XOR kc)=39 Or (sc XOR kc)= 92 Or (sc XOR kc)<32 Or (sc XOR kc)>126 Then
s = Chr(sc)
Else
s = Chr(sc XOR kc)
End If
ds = ds & s
kp = kp + 1
sp = sp + 1
If kp >= Len(key) Then
kp = 1
End If
Loop
d = ds
End Function
#3
+1
#4
多谢hookee老大,不过这个函数有点问题,vbs跟js的结果只有前8位是对的,后边都不同。
请看例子:
请看例子:
function d(os){
var key="DecryptIT";
var ds;
ds="";
var kp,sp,s,kc,sc;
kp=0;
sp=0;
while(sp<os.length){
sc=os.charCodeAt(sp);
kc=key.charCodeAt(kp);
if(((sc^kc)==39)||((sc^kc)==92)||((sc^kc)<32)||((sc^kc)>126)){
s=String.fromCharCode(sc);
}else {
s=String.fromCharCode((sc^kc));
}
ds+=s;
kp++;
sp++;
if(kp>=key.length){
kp=0;
}
}
return ds;
}
alert(d("w&UJNDBDbCV&@IBD{dvUP1OHB|buSWA<BD{dw&U6OEC}"));
Function d(os)
Dim key : key = "DecryptIT"
Dim ds
ds = ""
Dim kp,sp,s,kc,sc
kp = 1
sp = 1
Do While sp <= Len(os)
sc = Asc(Mid(os, sp, 1))
kc = Asc(Mid(key, kp, 1))
If (sc XOR kc)=39 Or (sc XOR kc)= 92 Or (sc XOR kc)<32 Or (sc XOR kc)>126 Then
s = Chr(sc)
Else
s = Chr(sc XOR kc)
End If
ds = ds & s
kp = kp + 1
sp = sp + 1
If kp >= Len(key) Then
kp = 1
End If
Loop
d = ds
End Function
msgbox(d("w&UJNDBDbCV&@IBD{dvUP1OHB|buSWA<BD{dw&U6OEC}"))
#5
Function d(os)
Dim key : key = "DecryptIT"
Dim ds
ds = ""
Dim kp,sp,s,kc,sc
kp = 1
sp = 1
Do While sp <= Len(os)
sc = Asc(Mid(os, sp, 1))
kc = Asc(Mid(key, kp, 1))
If (sc XOR kc)=39 Or (sc XOR kc)= 92 Or (sc XOR kc)<32 Or (sc XOR kc)>126 Then
s = Chr(sc)
Else
s = Chr(sc XOR kc)
End If
ds = ds & s
kp = kp + 1
sp = sp + 1
If kp > Len(key) Then
kp = 1
End If
Loop
d = ds
End Function
#6
漂亮!多谢hookee兄,您的无私奉献帮助让我解决了难题,相信也有很多人得到您的帮助,致敬!