不错的主要用于加密的vbs(asp)位移运算类

2018-09-06 11:00

阅读:618

  <scriptlanguage=vbscript>
Aother:奔腾的心
QQ:7180001
Date:2008-01-17

ClassmShift

Privatem_lPower2(31)

PublicFunctionRShift(ByVallThis,ByVallBits)
OnErrorResumeNext
Init
If(lBits<=0)Then
RShift=lThis
ElseIf(lBits>63)Then
..error...
ElseIf(lBits>31)Then
RShift=0
Else
If(lThisAndm_lPower2(31-lBits))=m_lPower2(31-lBits)Then
RShift=(lThisAnd(m_lPower2(31-lBits)-1))*m_lPower2(lBits)Or
m_lPower2(31)
Else
RShift=(lThisAnd(m_lPower2(31-lBits)-1))*m_lPower2(lBits)
EndIf
EndIf
EndFunction

PublicFunctionLShift(ByVallThis,ByVallBits)
OnErrorResumeNext
Init
If(lBits<=0)Then
LShift=lThis
ElseIf(lBits>63)Then
...error...
ElseIf(lBits>31)Then
LShift=0
Else
If(lThisAndm_lPower2(31))=m_lPower2(31)Then
LShift=(lThisAnd&H7FFFFFFF)\m_lPower2(lBits)Orm_lPower2(31-lBits)
Else
LShift=lThis\m_lPower2(lBits)
EndIf
EndIf
EndFunction

PrivateSubInit()
OnErrorResumeNext
m_lPower2(0)=&H1&
m_lPower2(1)=&H2&
m_lPower2(2)=&H4&
m_lPower2(3)=&H8&
m_lPower2(4)=&H10&
m_lPower2(5)=&H20&
m_lPower2(6)=&H40&
m_lPower2(7)=&H80&
m_lPower2(8)=&H100&
m_lPower2(9)=&H200&
m_lPower2(10)=&H400&
m_lPower2(11)=&H800&
m_lPower2(12)=&H1000&
m_lPower2(13)=&H2000&
m_lPower2(14)=&H4000&
m_lPower2(15)=&H8000&
m_lPower2(16)=&H10000
m_lPower2(17)=&H20000
m_lPower2(18)=&H40000
m_lPower2(19)=&H80000
m_lPower2(20)=&H100000
m_lPower2(21)=&H200000
m_lPower2(22)=&H400000
m_lPower2(23)=&H800000
m_lPower2(24)=&H1000000
m_lPower2(25)=&H2000000
m_lPower2(26)=&H4000000
m_lPower2(27)=&H8000000
m_lPower2(28)=&H10000000
m_lPower2(29)=&H20000000
m_lPower2(30)=&H40000000
m_lPower2(31)=&H80000000
EndSub

EndClass

Dimsft
Setsft=NewmShift
MsgBoxsft.RShift(200,4)
MsgBoxsft.LShift(200,4)
Setsft=Nothing
</script>


<scriptlanguage=javascript>
alert(200<<4);
alert(200>>4);
</script>


评论


亲,登录后才可以留言!