IP 주소 세분화 계산
<scriptLanguage = "jscript"runat = "server">
functionipdecode (eip) {
varip1, ip2, ip3, ip4;
IP1 = MoveByter (EIP & 0XFF000000,3);
IP2 = MoveByter (EIP & 0x00FF0000,2);
IP3 = MoveByter (EIP & 0x0000ff00,1);
IP4 = EIP & 0x000000ff;
returnip1+"."+IP2+"."+IP3+"."+IP4;
}
functionMoveBytel (num, bytenum) {
returnnum << = (bytenum*8)
}
functionmoveByter (num, bytenum) {
returnnum >>> = (bytenum*8)
}
</스크립트>
VBS에는 비트 작업이 없으므로 페이지에서 JS 및 VBS를 사용하는 것은 좋지 않습니다. VBS를 사용하는 경우에도 괜찮지 만 약간의 장점입니다. 그리고 한 가지는 약간 눈에 띄는 것입니다. VBS에서 분할 ( "202.102.29.6", ".")을 나누면 3 개의 숫자 202, 102 및 29가 표시되며 마지막 6 개를 얻지 못하므로 IP를 분할하도록 IP를 변경해야합니다 ( "202.102.29.6"& ".". ").
나는 VBS로 그것을했는데 비트 작동이 없기 때문에 더 번거 롭습니다.
<%
functionip2int (ipstr)
Dimiptemp, Max
iptemp = split (ipstr & ".", ".")
max = ubund (iptemp)
ifmax <> 4then
종료 기능
endif
Dima, B, i
a = "& h"
fori = 0to3
b = 16 진수 (iptemp (i))
iflen (b) = 1then
b = "0"& b
endif
a = a & b
다음
ip2int = clng (a)
최종 기능 장애
functionInt2IP (IP)
dimiptemp, a, ipstr, i, 길이
iptemp = hex (IP)
길이 = 8-len (iptemp)
fori = 1 톨 길이
iptemp = "0"& iptemp
다음
a = 왼쪽 (iptemp, 2)
a = "& h"& a
i = cint (a)
a = cstr (i)
ipStr = a & "."
a = mid (iptemp, 3,2)
a = "& h"& a
i = cint (a)
a = cstr (i)
ipStr = ipstr & a & "."
a = mid (iptemp, 5,2)
a = "& h"& a
i = cint (a)
a = cstr (i)
ipStr = ipstr & a & "."
a = 오른쪽 (iptemp, 2)
a = "& h"& a
i = cint (a)
a = cstr (i)
ipStr = ipStr & a
int2ip = ipstr
최종 기능 장애
dimtestip, testint
testip = "202.102.29.6"
testint = ip2int (testip)
response.writeTestip & "WillBeencodedTo <fontColor = red>"& testint & "</font> <br>"
response.writeTestip & "WillBedEncodedTo <fontColor = red>"& int2ip (testint) & "</font> <br>"