返回列表 发帖

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

class Base64Class
2 I5 S' r$ d8 f" Q  rem Const 7 @2 ~5 n" ~% s( ?; X! c
  dim sBASE_64_CHARACTERS'转化码
: V! B# W) }' c/ Q! V. f9 E7 ]  dim lenString '计算字符串的长度
3 |# ~9 P- O- r4 K; y- O  dim iCount '计数器
4 P  g9 T6 @+ M" _+ T  G3 z  dim returnValue '返回值 1 v4 ?* b" F0 A, t5 B/ r, y0 P, t* f
  dim tempChar'缓存字符 / X! p1 {5 d; Q
  dim tempString'缓存字符串 3 _6 N! O* ~: g; n" l
  dim paramString '参数字符串
) t0 R4 s7 w( X0 G  dim temHex'缓存缓存十六进制 # _* r1 @' o  L# z: W2 d
  dim tempLow'缓存低位
; f$ Y; I4 Q  {  ?, N! T  dim tempHigh'缓存高位
6 |7 H: \# r8 I4 j0 f  dim mod3String' 4 _- ]& Y1 W# a8 O5 {
  dim mod4String'
/ @5 {+ O* E9 c0 p3 \& O  dim tempBinary'
6 ~9 }# n  ^" ^/ S8 x( m  dim tempByteOne' 2 M" o. G( C4 n% ^9 s
  dim tempByteTwo' : P9 r  ]' H  O5 e- q
  dim tempByteThree'
  C- W+ k& p3 N# \$ ~: c% _- C  dim tempByteFour' 0 G/ J( l- p7 b/ B' d7 I* @
  dim tempSaveBitsOne' + H& Q0 U6 `$ V& F# G
  dim tempSaveBitsTwo' , A5 M6 ^  b; D. `. j
  '********************************************& [1 V) S: m, d8 s: g) ~, p
  'begin初始化类 ; _/ D& s  d. x4 t
  '********************************************
; [/ Z+ t- Q3 G4 x" q9 j' Y7 f  private sub Class_Initialize() 5 Z0 M6 z+ [" j  c% c9 x3 c! K
  sBASE_64_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" end sub : P2 w: d! c8 [* H' p( }
  '********************************************
  w+ q, p- A& w( @; q2 M: @  'end初始化类 '! _' M6 m7 [5 S
  ******************************************** + G( \. l+ g& h6 B+ c% n5 w
  '******************************************** ' o) N3 j, N, U# `: {& s
  'begin销毁类
7 z& [3 N: ^& I$ @4 k' }0 E  '******************************************** 6 W5 b+ h9 q% m' I
  Private Sub Class_Terminate() ) W, Y- e  d: i- F& _+ s9 m& _
  sBASE_64_CHARACTERS="" end sub 1 f! a, ~' H/ R0 m5 E& M! ~
  '********************************************
: R; m9 F+ B7 E" D' s- q  'end销毁类 # G; [, W  n- m/ |
  '********************************************4 ~  k; x* w" ^
  '******************************************** * a: J% E  ?/ ?) o5 L7 g
  'begin将Ansi编码的字符串进行Base64编码 & h2 M/ ~/ ^( y! g
  '******************************************** 5 a" M7 E$ K: l/ q) m. Q
  public function Encode(paramString)
2 _  O+ o! O! C9 I7 q* \! J+ M$ P  tempString="" " v9 q7 ^4 B3 p! i# _
  returnValue=""
7 E" o/ y  k, r  lenString=len(paramString) 3 W, l7 m( k# j; p
  if lenString<1 then $ O, f3 Z9 d, W' v
  Encode=returnValue # |6 z: ]2 t5 X9 ^& A
  else % h( b; m2 \5 X* s& ~- O/ B6 D
  mod3String=lenString mod 3 8 }% j/ G( d9 X6 V9 o! I
  '补足位数是为了便于计算 3 O0 b% w( J6 c" t8 U& K. ^! m
  if mod3String>0 then 5 u$ e8 {5 e3 Q& @# u% j
  lenString=lenString+3-mod3String % T( @( K' H: Y; A
  lenString=lenString-3
# b$ J/ m. ?0 z5 Q# _# d: k) E1 h9 h  end if

返回列表