返回列表 发帖

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

class Base64Class
. a+ C3 n/ h  I6 R  rem Const * `1 d1 `0 O8 ]2 O3 N' _& W$ w; \
  dim sBASE_64_CHARACTERS'转化码
6 K: N. k# L* r: j/ J  dim lenString '计算字符串的长度
: `0 Q: Z5 T  B( o; C  dim iCount '计数器
, S0 {8 a0 Z/ K1 ~& \  dim returnValue '返回值
: j' R# N2 F4 {/ W! Q  x  dim tempChar'缓存字符
) n8 p: M+ D! t+ i. t3 m  dim tempString'缓存字符串 / w' \8 k' @- |1 S% l0 t5 u
  dim paramString '参数字符串 " G3 B: C$ s6 e' ], t7 a# v
  dim temHex'缓存缓存十六进制 , h/ ~: x: q0 c0 N" s3 S' V
  dim tempLow'缓存低位 : L+ x" X4 h0 O% |; c; C$ c7 A" L
  dim tempHigh'缓存高位
2 X0 t0 j7 w2 y  dim mod3String'
, o. r" ]; k/ U- R2 u: z  dim mod4String'
: `1 E3 N0 C$ ]) S! o( a  dim tempBinary' 3 n! W+ c3 Y1 B; B: L9 N
  dim tempByteOne' . V! t, g1 y% ]. A
  dim tempByteTwo' 5 h0 W& Z0 z# K, W9 r  Q
  dim tempByteThree' 1 x0 B' q! H" d- O* ?
  dim tempByteFour' ) o; u5 ]% p5 @' U
  dim tempSaveBitsOne'   U8 p. j& h& X$ S7 A7 W) f
  dim tempSaveBitsTwo'
6 W' m/ Y5 C+ w5 Q" B) J( Q# p4 e- v  '********************************************
, l; F7 D$ [! n* b  'begin初始化类
8 k! l. W: A$ n% Q  x5 U+ i! s  '********************************************
5 c- ~5 `/ D+ {2 u& f  private sub Class_Initialize()
" e) }3 x5 S4 ^+ K5 v4 `  sBASE_64_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" end sub
; y% S2 o6 ^- m- J9 b$ g( v9 s2 l( F  '********************************************
" `' Z2 _& j8 S7 j" F& Q  'end初始化类 '4 z7 o  I! ]! f$ {/ A& R
  ******************************************** : ^& ?5 L) P6 J, \
  '******************************************** 4 p" q3 f. ]# T9 _& v
  'begin销毁类 , G8 }1 s5 [4 b0 ^
  '******************************************** 8 [3 j' k9 f8 G1 z) J: Q7 `
  Private Sub Class_Terminate() 2 W; m6 _/ i1 [9 Y; ]0 t& L4 H
  sBASE_64_CHARACTERS="" end sub $ q7 ~" D% S& I6 ~' w) z9 o; g
  '******************************************** 2 v0 Z/ b/ D: P( p4 L
  'end销毁类 2 @2 B4 Q2 M: ~. P1 L
  '********************************************0 U- A  V% v& z) Y
  '********************************************
$ U+ V" g! A3 M5 p/ o  Q2 n  'begin将Ansi编码的字符串进行Base64编码
, S( P( N$ k0 J$ l" f$ X# ^  '******************************************** % I$ I7 B2 \% V3 V: o6 G
  public function Encode(paramString) 0 E# j7 l! w! G* D" c4 m
  tempString="" / ^. q/ X/ x, [- y, o6 M2 e
  returnValue="" # I$ |, Q8 o. W  U0 \- L$ S/ W( g
  lenString=len(paramString)
6 H2 Q5 i+ r+ R5 e  W  if lenString<1 then
' o  e1 m2 L' |0 H) ?! _- B  Encode=returnValue   x* w& Y+ s. _! o' H; ]# N6 C
  else   i8 Y* I% F3 m* J4 o, }) l
  mod3String=lenString mod 3 4 [0 X$ U5 z8 @1 L" \- V( v
  '补足位数是为了便于计算 / N; M4 `7 e# v8 b$ w
  if mod3String>0 then
* H7 j+ J5 n" J  lenString=lenString+3-mod3String
" _3 f4 t9 z* m$ Z$ w( G  lenString=lenString-3
' A7 J5 s; M$ Q5 q3 [2 j4 k  end if

返回列表