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 = len(password)
il_x = 0
il_y = 0
is_out = ""
for i = 1 to il_len
il_bit = ascw(mid(password, i, 1)) 'w系列支持unicode
il_y = (il_bit * 13 mod 256) + il_x
is_out = is_out & chrw(fix(il_y)) '取整 int和fix区别: fix修正负数
il_x = il_bit * 13 / 256
next
is_out = is_out & chrw(fix(il_x))
password = is_out
il_len = len(password)
il_x = 0
il_y = 0
is_out = ""
for i = 1 to il_len
il_bit = ascw(mid(password, i, 1))
'取前4位值
il_y = il_bit / 16 + 64
is_out = is_out & chrw(fix(il_y))
'取后4位值
il_y = (il_bit mod 16) + 64
is_out = is_out & chrw(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 = len(password)
il_x = 0
il_y = 0
is_out = ""
for i = 1 to il_len step 2
il_bit = ascw(mid(password, i, 1))
'取前4位值
il_y = (il_bit - 64) * 16
'取后4位值
'dd = ascw(mid(password, i + 1, 1)) - 64
il_y = il_y + ascw(mid(password, i + 1, 1)) - 64
is_out = is_out & chrw(il_y)
next
il_x = 0
il_y = 0
password = is_out
is_out = ""
il_len = len(password)
il_x = ascw(mid(password, il_len, 1))
for i = (il_len - 1) to 1 step -1
il_y = il_x * 256 + ascw(mid(password, i, 1))
il_x = il_y mod 13
is_out = chrw(fix(il_y / 13)) & is_out
next
userdecode = is_out
end function