国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > ASP > 正文

ASP BASE64加解密(親測(cè)可用)

2024-05-04 11:09:51
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
之前腳本之家小編已經(jīng)為大家分享了了幾個(gè)asp BASE64加解密函數(shù)代碼,不過(guò)實(shí)際用的過(guò)程中都有這樣或那樣的問(wèn)題,現(xiàn)在重新整理一個(gè)

核心代碼:

<% ' OPTION EXPLICITconst BASE_64_MAP_INIT = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"dim newlinedim Base64EncMap(63)dim Base64DecMap(127)'初始化函數(shù)PUBLIC SUB initCodecs()' 初始化變量newline = "<P>" & chr(13) & chr(10)dim max, idxmax = len(BASE_64_MAP_INIT)for idx = 0 to max - 1Base64EncMap(idx) = mid(BASE_64_MAP_INIT, idx + 1, 1)nextfor idx = 0 to max - 1Base64DecMap(ASC(Base64EncMap(idx))) = idxnextEND SUB'Base64加密函數(shù)PUBLIC FUNCTION base64Encode(plain)if len(plain) = 0 thenbase64Encode = ""exit functionend ifdim ret, ndx, by3, first, second, thirdby3 = (len(plain) / 3) * 3ndx = 1do while ndx <= by3first = asc(mid(plain, ndx+0, 1))second = asc(mid(plain, ndx+1, 1))third = asc(mid(plain, ndx+2, 1))ret = ret & Base64EncMap( (first / 4) AND 63 )ret = ret & Base64EncMap( ((first * 16) AND 48) + ((second / 16) AND 15 ) )ret = ret & Base64EncMap( ((second * 4) AND 60) + ((third / 64) AND 3 ) )ret = ret & Base64EncMap( third AND 63)ndx = ndx + 3loopif by3 < len(plain) thenfirst = asc(mid(plain, ndx+0, 1))ret = ret & Base64EncMap( (first / 4) AND 63 )if (len(plain) MOD 3 ) = 2 thensecond = asc(mid(plain, ndx+1, 1))ret = ret & Base64EncMap( ((first * 16) AND 48) + ((second / 16) AND 15 ) )ret = ret & Base64EncMap( ((second * 4) AND 60) )elseret = ret & Base64EncMap( (first * 16) AND 48)ret = ret '& "="end ifret = ret '& "="end ifbase64Encode = retEND FUNCTION'Base64解密函數(shù)PUBLIC FUNCTION base64Decode(scrambled)if len(scrambled) = 0 thenbase64Decode = ""exit functionend ifdim realLenrealLen = len(scrambled)do while mid(scrambled, realLen, 1) = "="realLen = realLen - 1loopdim ret, ndx, by4, first, second, third, fourthret = ""by4 = (realLen / 4) * 4ndx = 1do while ndx <= by4first = Base64DecMap(asc(mid(scrambled, ndx+0, 1)))second = Base64DecMap(asc(mid(scrambled, ndx+1, 1)))third = Base64DecMap(asc(mid(scrambled, ndx+2, 1)))fourth = Base64DecMap(asc(mid(scrambled, ndx+3, 1)))ret = ret & chr( ((first * 4) AND 255) + ((second / 16) AND 3))ret = ret & chr( ((second * 16) AND 255) + ((third / 4) AND 15))ret = ret & chr( ((third * 64) AND 255) + (fourth AND 63))ndx = ndx + 4loopif ndx < realLen thenfirst = Base64DecMap(asc(mid(scrambled, ndx+0, 1)))second = Base64DecMap(asc(mid(scrambled, ndx+1, 1)))ret = ret & chr( ((first * 4) AND 255) + ((second / 16) AND 3))if realLen MOD 4 = 3 thenthird = Base64DecMap(asc(mid(scrambled,ndx+2,1)))ret = ret & chr( ((second * 16) AND 255) + ((third / 4) AND 15))end ifend ifbase64Decode = retEND FUNCTION%>

使用方法:

' 初始化 call initCodecsResponse.Write(base64Encode("腳本之家之我要加密的字符串"))Response.Write(base64Decode("bWFyczIwMTAwMjIw0"))

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 贵德县| 新闻| 呼图壁县| 安溪县| 镇坪县| 五常市| 青州市| 洪雅县| 南通市| 新晃| 登封市| 安国市| 临夏县| 广德县| 云龙县| 资源县| 衡阳市| 灌云县| 南郑县| 锡林浩特市| 新郑市| 普格县| 铁岭县| 曲靖市| 阿尔山市| 稻城县| 收藏| 故城县| 前郭尔| 家居| 邵阳县| 泰安市| 资兴市| 巴彦淖尔市| 洛川县| 宜君县| 莎车县| 香港 | 绵阳市| 太和县| 桃园市|