# 05-25日<一个简单实用的 vb 加密/解密算法>之改进

1 篇文章 0 订阅

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_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))

il_x = 0
il_y = 0
is_out = ""
For i = 1 To il_len
'取前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_x = 0
il_y = 0
is_out = ""
For i = 1 To il_len Step 2
'取前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
is_out = ""

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

• 0
点赞
• 1
收藏
觉得还不错? 一键收藏
• 打赏
• 0
评论
01-06 3284
06-02 954
10-12 2218
06-15 2303
07-10
09-24
06-03
06-19
09-22
07-02
04-28 2014

### “相关推荐”对你有帮助么？

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

neil

¥1 ¥2 ¥4 ¥6 ¥10 ¥20

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、付费专栏及课程。