返回列表 发帖

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

class Base64Class+ Q: l. Q. V5 t; `7 Q) p  T# V
  rem Const 0 k  |6 G, ~" g+ L
  dim sBASE_64_CHARACTERS'转化码 + N7 i5 H! X1 q  \' @& q( @5 p9 i/ D
  dim lenString '计算字符串的长度
8 T' ?& j6 S0 H3 s: L# l( _" f1 d/ l  dim iCount '计数器
; q6 K7 I" c4 H+ d4 O" ^  dim returnValue '返回值
3 _$ L0 ?: o. A: a" y! J9 K  dim tempChar'缓存字符
0 {" ~2 A* n, v/ ~0 X; B  dim tempString'缓存字符串 6 R! {7 r- U# i' ~: o
  dim paramString '参数字符串 . f! j$ |4 Z% }" d  x) o9 [/ x
  dim temHex'缓存缓存十六进制
, o& n& Z3 D6 y  R  dim tempLow'缓存低位 , d8 n, r( ~% b# U4 {0 b
  dim tempHigh'缓存高位
; l8 m& Q  n* V8 A3 U) N0 B' d  dim mod3String' ' `" Z2 t8 x7 [9 W) u3 T
  dim mod4String'
; V' Q: @- Y, u0 Y- [& ?8 r) c9 F  dim tempBinary'
- x, Q3 ~' @7 ?, ^; u  dim tempByteOne'
" W) A! J1 \7 |  dim tempByteTwo'
, }0 L6 b$ S0 p5 D  a# Q, @) |  dim tempByteThree'
5 g  Q# v0 N9 z" b1 `  dim tempByteFour'
; n1 @& d" g! h0 y4 ?  dim tempSaveBitsOne' 7 B' z* n5 H; `# {: t! I
  dim tempSaveBitsTwo'
% m' ?* `% _3 \) }$ d) N  '********************************************
+ s% T/ m3 B. ~2 `  'begin初始化类
7 _$ k, y- n' b. j  '******************************************** ) w! @. ^$ T3 S
  private sub Class_Initialize()
$ s, @% ]4 a5 e$ S  sBASE_64_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" end sub + a2 Q, h' Z+ i
  '********************************************
" j" g3 O2 c9 [% n% E( C1 f  'end初始化类 '
" g$ z6 [$ B4 |6 @' L  F  ********************************************
! V& x+ i$ d: w& G3 z8 L  '******************************************** ) H& l  l8 `& h7 u9 L( m1 y
  'begin销毁类
! V( K* b+ }6 L  '********************************************
/ N8 a9 ?0 o1 z* }6 T% n( }% ^  Private Sub Class_Terminate() 0 M& A  _, Z! k2 M+ L2 N
  sBASE_64_CHARACTERS="" end sub 6 _  l7 H+ _! ~3 |- r3 p! P
  '********************************************
- q# }2 g6 O0 [3 |6 q" s; }  'end销毁类
$ G& [) k2 t8 Y8 X# }  '********************************************
6 c/ \- w/ f8 M; v9 L5 |5 a  '********************************************
1 D- \: i6 N. i2 i. w  'begin将Ansi编码的字符串进行Base64编码 1 f9 c& _3 A( H. i- W
  '******************************************** ! S4 k- A/ I( m
  public function Encode(paramString) 4 U! m; J" j* f* h1 t) E
  tempString=""
! U  M& V3 Q2 \5 V  returnValue=""
9 M, ?; w/ [' P' q4 N) y  lenString=len(paramString)
% J: \6 `5 g6 `+ c2 P  if lenString<1 then
, A7 X) h/ g7 u! I. \  Encode=returnValue
( N5 L8 d& Q2 J# z  else " Z) j1 a/ d0 [
  mod3String=lenString mod 3
) z, }$ f' X9 D1 p1 w, `  '补足位数是为了便于计算 / A% H  p3 i8 A3 E8 c
  if mod3String>0 then   y4 S5 v# t; R$ m, L0 F: c* j
  lenString=lenString+3-mod3String
* c2 v) s. o9 _& H  g  lenString=lenString-3 ; `# O4 B( G* S, r5 f4 J
  end if

返回列表