返回列表 发帖

[原创文章] ASP编写的加密和解密类

class Base64Class
: U8 P+ X# G; p8 G  rem Const
: E. k$ p8 i( E' f1 c% z, Y) d  dim sBASE_64_CHARACTERS'转化码 + f. v& n  Z9 b2 l
  dim lenString '计算字符串的长度
* k/ h' p' I3 U: K- \  dim iCount '计数器 " c7 }) O/ A& q& ?$ ]8 ^( |0 [: w
  dim returnValue '返回值 * w8 \1 c( r/ `$ @  y' p
  dim tempChar'缓存字符
' P+ ~, U: d- A7 O1 i8 w# n  dim tempString'缓存字符串 4 F5 l# P- N: c: [) G. f, j/ r+ _3 O
  dim paramString '参数字符串
' g: W! ~, {. X: r* p# n& m, [  dim temHex'缓存缓存十六进制 7 {( [+ h" C" o) c# u# V$ d# a
  dim tempLow'缓存低位
* o8 ~$ R; I3 L0 e: `: A  dim tempHigh'缓存高位 9 U# {. M5 i! ?
  dim mod3String'
3 x* N; v& O. [, J* B* g7 h  dim mod4String'
: `* h5 A2 ~- S# _  dim tempBinary'
! p, W+ W4 s1 l4 C0 M* [( A  dim tempByteOne' 3 z2 Y6 R/ P. Y/ ~3 N" t3 i: u& t
  dim tempByteTwo' % G+ b) S0 _, ~
  dim tempByteThree' / N$ i$ c) {$ B( j+ O- g" d
  dim tempByteFour'
4 ~( _$ a) V+ w; y+ O6 W  dim tempSaveBitsOne' " h2 [' k- s4 J  I  k: u( j" I* |% _
  dim tempSaveBitsTwo' 9 z, u8 p5 t0 |8 a
  '********************************************7 e. `7 h: M5 Y; D; ?( L6 b
  'begin初始化类 & |" `& P3 D9 b$ T1 d5 k  i6 Z
  '******************************************** + @* R" X5 r/ N2 s& ^7 @5 r
  private sub Class_Initialize() 8 }- R3 ]$ ]; S; S
  sBASE_64_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" end sub 1 e4 {2 b3 X' S$ Q# j1 ^
  '******************************************** 9 [: B+ @8 E3 @; ^$ a# a
  'end初始化类 '
+ o2 W! k# x& @/ {' R  ********************************************
  t5 s( q' r/ i8 u& B) ^  '******************************************** & q4 X# i; U' n
  'begin销毁类 9 {; o, Z* j6 N' _; }
  '******************************************** , c0 \' r5 n2 \. ?" i
  Private Sub Class_Terminate()
; t' v) T# f& f& {% H' G7 E  sBASE_64_CHARACTERS="" end sub 1 @' ^7 s* G. j" b; a
  '******************************************** 4 {7 ~: {& g! \* U7 ]( F' q
  'end销毁类
# z- d5 o+ L% U2 Q2 h  '********************************************/ L' v  `- ?) Q% ~
  '******************************************** ) H, t8 e; X+ L' {  g3 `
  'begin将Ansi编码的字符串进行Base64编码 8 f+ s5 _& L1 q8 k# u
  '******************************************** 1 R! H: B3 ~* v! s$ @: U
  public function Encode(paramString) 6 ?6 X$ q( ]$ N/ l: J
  tempString="" ! y1 z9 w. L: m2 i
  returnValue="" # I1 x, |: d3 ^& g
  lenString=len(paramString) ; G0 H, C. b$ }7 r9 S+ o4 k
  if lenString<1 then ; o7 o3 s! I$ X% k& h- i9 |% ~! R
  Encode=returnValue
* B8 ~! [5 g4 d9 x) k  else & T1 N$ Z. O1 w: ]( t
  mod3String=lenString mod 3
4 P: G, `5 Y! o: w. u8 q  '补足位数是为了便于计算 . ?! E) l: j; p& ]6 I' ]
  if mod3String>0 then
! |) i' \9 u! w% H, C  lenString=lenString+3-mod3String * F% y( K0 l( R# v  @' F& ?& _
  lenString=lenString-3
& [! x( r: S5 B' L9 S$ P8 w  end if

返回列表