Core code:
<% ' OPTION EXPLICIT const BASE_64_MAP_INIT = ' abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789+/' Dim newline Dim Base64encmap () Dim base64decmap (127) ' Initialize function public SUB initcodecs () ' Initialize variable new line = "<P>" & Chr (a) & CHR Dim max, idx max = Len (base_64_map_init) for idx = 0 to Ma X-1 base64encmap (idx) = Mid (Base_64_map_init, IDX + 1, 1) next for idx = 0 to Max-1 base64de CMap (ASC (Base64encmap (idx)) = idx Next End SUB ' Base64 cryptographic function Public Function base64encode (plain) If Len (
Plain = 0 Then Base64Encode = "" Exit Function End If Dim ret, Ndx, By3, I, second, third
By3 = (len (plain) \ 3) * 3 NDX = 1 Do While ndx <= by3-i = ASC (Mid (Plain, ndx+0, 1)) Second = ASC (Mid (Plain, ndx+1, 1)) Third = ASC (Mid (Plain, ndx+2, 1)) ret = ret & Base64encmap ((a) \ 4) and () ret = ret & Base64encmap (((a) + ((second)) ret = ret & Base64encmap ((Seco nd * 4) and ((third) and 3)) ret = ret & Base64encmap (third and) Ndx = ndx + 3 L OOP if by3 < Len (plain) then-i = ASC (Mid (Plain, ndx+0, 1)) ret = ret & Base64encmap ((Firs T \ 4) and-(Len (Plain) MOD 3) = 2 Then second = ASC (Mid (Plain, ndx+1, 1)) ret = ret & Amp Base64encmap ((a) ((a) + ((second)) ret = ret & Base64encmap ((Second * 4) and else ret = ret & Base64encmap ((a) ret = Ret ' & "=" End If ret = Ret ' & ' = ' End If Base64Encode = ret End Function ' Base64 decryption function public functions BAS E64decode (scrambled) if Len (scrambled) = 0 Then Base64decode = "" Exit Function End If Dim Reallen Reallen = len (scrambled) Do while mid (scrambled, Reallen, 1) = "=" Reallen = realLen-1 loop Dim ret, ND
X, By4, second, third, fourth ret = "" By4 = (reallen \ 4) * 4 NDX = 1 Do while ndx <= by4
i = BASE64DECMAP (ASC (Scrambled, ndx+0, 1)) Second = Base64decmap (ASC (Mid (Scrambled, ndx+1, 1))
Third = Base64decmap (ASC (Scrambled, ndx+2, 1)) Fourth = Base64decmap (ASC (Mid (Scrambled, ndx+3, 1)) RET = ret & Chr ((4) and 255) + ((second) and 3) ret = RET & Chr ((second *) and
255) + ((third \ 4)) ret = ret & Chr ((third *) and 255) + (fourth and)) Ndx = Ndx + 4 Loop if Ndx < Reallen then-i = Base64decmap (ASC (Mid scrambled, ndx+0, 1)) Second = Base6
4DECMAP (ASC (Scrambled, ndx+1, 1)) ret = ret & Chr (((4) and 255) + ((second) and 3)) If Reallen MOD 4 = 3 THen third = Base64decmap (ASC (Mid scrambled,ndx+2,1)) ret = ret & Chr ((second *) and 255) + ( (Third \ 4) ) End If End If Base64decode = Ret end FUNCTION%>
How to use:
' Initialize call
initcodecs
Response.Write (Base64Encode ("The string that I want to encrypt in the cloud community")
Response.Write (Base64decode (" BWFyczIwMTAwMjIw0 "))