返回列表 发帖

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

class Base64Class
& B7 v% \: a- B  rem Const
9 N& x+ W, y# M  dim sBASE_64_CHARACTERS'转化码
4 f: J) c( Z1 Q3 p9 c5 K1 E% c  dim lenString '计算字符串的长度 7 w8 M4 M2 |& w8 e
  dim iCount '计数器
2 Z6 }. _+ E5 i* d  dim returnValue '返回值 8 m- v+ o7 q  F3 n: U
  dim tempChar'缓存字符
" I4 B  _, ~4 R/ x3 O, O  dim tempString'缓存字符串
5 X0 Q  l  q3 \* A* j' @9 q. n& B  dim paramString '参数字符串 / c* n, y3 a9 v( x) {# v
  dim temHex'缓存缓存十六进制
% L2 |" f) Z" _) B4 k4 w# j, f2 C* F  dim tempLow'缓存低位 ; X  c# W& z& }# }
  dim tempHigh'缓存高位
% G. W1 I, ]" C3 u8 K6 Z% p  dim mod3String'
+ d( f* a  \1 |, j# e; ^  dim mod4String'
, c) s3 u- Y) P" q9 R/ B  dim tempBinary'
$ |' }( z  i- k/ @  dim tempByteOne' $ b& ^9 z1 _7 v: x6 _8 b
  dim tempByteTwo' % v# A8 ?. @: c
  dim tempByteThree'
5 g2 q1 z5 |( }$ [! p% e  dim tempByteFour' + a( H1 P) u+ q: n
  dim tempSaveBitsOne' 7 q' F/ ?# A3 @" @$ W  a& M; r
  dim tempSaveBitsTwo'
/ F6 t) V1 m" B% |: q  '********************************************4 j$ Z# W  N3 P$ k$ u( f
  'begin初始化类
2 h( A7 }. g4 S  A% A# a" u  '********************************************
8 W4 ~  _# @0 {( o! a: C- `* R0 k  private sub Class_Initialize() 3 u0 G0 E1 W/ S4 @, y# U
  sBASE_64_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" end sub
$ L2 J. ?0 f' v" ~7 W  y  '******************************************** * W2 Z3 Z7 s2 T9 X  z. K# [
  'end初始化类 '# k- L. i( f" v6 [4 l& W
  ******************************************** : ]9 a1 w5 {: n  u- x' D
  '********************************************
( v' G% D* J+ n* b! b; `8 F$ b# s+ ~  'begin销毁类 6 d: B( D; `. I. @" q3 U
  '********************************************
, s: ?- B! D6 i. m  Private Sub Class_Terminate() ) S4 y( r0 B+ x: `
  sBASE_64_CHARACTERS="" end sub ' w  g2 n! t  }( b6 p
  '******************************************** * y) w$ r5 c3 `  ^) U' X  ^) Y* ]
  'end销毁类
6 G# _9 n& G" L8 {& q' @  '********************************************: T+ O' \' i) g
  '******************************************** 7 [: J9 d3 ?& @' M5 L3 L+ S+ r5 `
  'begin将Ansi编码的字符串进行Base64编码 & W, ?/ r' z7 J" e* F
  '********************************************
  ~2 @) i( _0 \! D: a9 g  public function Encode(paramString)
7 L$ h/ l* Y. K) A$ S1 @  tempString="" * E, a$ }4 G4 T2 T8 u, e
  returnValue=""
3 D+ z( u; [# ^. Z* u  S% R6 ]  lenString=len(paramString) 7 O8 S0 z3 M+ s6 W# o+ u
  if lenString<1 then # u- E* U+ I; ^( _+ e" f; X) I
  Encode=returnValue
4 W; }4 Y) ^8 w( I# Y& |  else 7 L0 m. ]* l3 f, r
  mod3String=lenString mod 3 ( j0 ~3 y  b* j+ f. w
  '补足位数是为了便于计算 # g; s( |6 e8 l/ W7 ?5 L
  if mod3String>0 then # [, \: l3 d% x- B
  lenString=lenString+3-mod3String 0 a( ~' A( L0 q# L* v  c- X, \
  lenString=lenString-3
. I' j7 B7 o& V2 R2 Q2 M: E  end if

返回列表