05-25日之改进

来源:互联网 发布:数据机房设计标准 编辑:程序博客网 时间:2024/04/30 08:05
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

在看了网友 everjoe评论后,俺改进了一下该程序,其实也就是把W系列的函数用B系列去替代,然后就支持中文加密了

修改后的全部代码入下:

Function UserCode(password As String) As String
'用户口令加密
    Dim il_bit, il_x, il_y, il_z, il_len, i As Long
    Dim is_out As String
    il_len = LenB(password)
    il_x = 0
    il_y = 0
    is_out = ""
    For i = 1 To il_len
        il_bit = AscB(MidB(password, i, 1))    'b系列支持中文
       
        il_y = (il_bit * 13 Mod 256) + il_x
        is_out = is_out & ChrB(Fix(il_y))  '取整 int和fix区别: fix修正负数
        il_x = il_bit * 13 / 256
    Next
    is_out = is_out & ChrB(Fix(il_x))
   
    password = is_out
    il_len = LenB(password)
    il_x = 0
    il_y = 0
    is_out = ""
    For i = 1 To il_len
        il_bit = AscB(MidB(password, i, 1))
        '取前4位值
        il_y = il_bit / 16 + 64
        is_out = is_out & ChrB(Fix(il_y))
        '取后4位值
        il_y = (il_bit Mod 16) + 64
        is_out = is_out & ChrB(Fix(il_y))
    Next
    UserCode = is_out
End Function


Function UserDeCode(password As String) As String
'口令解密
    Dim is_out As String
    Dim il_x, il_y, il_len, i, il_bit As Long

    il_len = LenB(password)
    il_x = 0
    il_y = 0
    is_out = ""
    For i = 1 To il_len Step 2
        il_bit = AscB(MidB(password, i, 1))
        '取前4位值
        il_y = (il_bit - 64) * 16
        '取后4位值
        'dd = AscW(Mid(password, i + 1, 1)) - 64
        il_y = il_y + AscB(MidB(password, i + 1, 1)) - 64
        is_out = is_out & ChrB(il_y)
    Next

    il_x = 0
    il_y = 0
    password = is_out
    is_out = ""

    il_len = LenB(password)
    il_x = AscB(MidB(password, il_len, 1))
    For i = (il_len - 1) To 1 Step -1
        il_y = il_x * 256 + AscB(MidB(password, i, 1))
        il_x = il_y Mod 13
        is_out = ChrB(Fix(il_y / 13)) & is_out
    Next
    UserDeCode = is_out
End Function

 

 

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击