| 网站首页 | 建站学院 | 资源下载 | 建站教程 | 图片素材 | 网贝社区 | 
您现在的位置: 网贝建站 >> 建站学院 >> ASP技术 >> 安全加密 >> 正文 用户登录 新用户注册
专 题 栏 目
最 新 热 门
最 新 推 荐
相 关 文 章
没有相关文章
一段加密函数(base64)         ★★★
一段加密函数(base64)
作者:佚名 文章来源:网海之贝 点击数: 更新时间:2004-8-27 16:06:46
Const sBASE_64_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"  


Function Base64encode(ByVal asContents)  
Dim lnPosition  
Dim lsResult  
Dim Char1  
Dim Char2  
Dim Char3  
Dim Char4  
Dim Byte1  
Dim Byte2  
Dim Byte3  
Dim SaveBits1  
Dim SaveBits2  
Dim lsGroupBinary  
Dim lsGroup64  

If Len(asContents) Mod 3 > 0 Then asContents = asContents & String(3 - (Len(asContents) Mod 3), " ")  
lsResult = ""  

For lnPosition = 1 To Len(asContents) Step 3  
    lsGroup64 = ""  
    lsGroupBinary = Mid(asContents, lnPosition, 3)  

    Byte1 = Asc(Mid(lsGroupBinary, 1, 1)): SaveBits1 = Byte1 And 3  
    Byte2 = Asc(Mid(lsGroupBinary, 2, 1)): SaveBits2 = Byte2 And 15  
    Byte3 = Asc(Mid(lsGroupBinary, 3, 1))  

    Char1 = Mid(sBASE_64_CHARACTERS, ((Byte1 And 252) 4) + 1, 1)  
    Char2 = Mid(sBASE_64_CHARACTERS, (((Byte2 And 240) 16) Or (SaveBits1 * 16) And &HFF) + 1, 1)  
    Char3 = Mid(sBASE_64_CHARACTERS, (((Byte3 And 192) 64) Or (SaveBits2 * 4) And &HFF) + 1, 1)  
    Char4 = Mid(sBASE_64_CHARACTERS, (Byte3 And 63) + 1, 1)  
    lsGroup64 = Char1 & Char2 & Char3 & Char4  
     
    lsResult = lsResult + lsGroup64  
Next  

Base64encode = lsResult  
End Function
文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)