string ls_password
string ls_password
int j
ls_password=''
for j=1 to len(password) //用户密码加密
ls_password=ls_password+char(asc(mid(Trim(password),j,1))-2*j)
next
ls_password = trim(ls_password)
return ls_password
int j
ls_password=''
for j=1 to len(password) //用户密码解密
ls_password=ls_password+char(asc(mid(Trim(password),j,1))+2*j)
next
ls_password = trim(ls_password)
return ls_password
string ls_password,ls_pubkey
long li_temp,li_len,ll_asc1,ll_asc2
function f_password(string fs_password,character fc_status)
//判断密码长度
li_len=len(fs_password)
if li_len>= 15 then
fs_password=left(fs_password,15)
else
fs_password=fs_password+space (15 - li_len)
end if
ls_password=""
CHOOSE CASE fc_status
CASE 'Z'//加密
for li_temp = 1 to 15
ll_asc1 = asc(mid(fs_password,li_temp,1))
ls_password = ls_password + char( ll_asc1 + 2 )
next
CASE 'U'//解密
for li_temp = 1 to 15
ll_asc1 = asc(mid(fs_password,li_temp,1))
ls_password = ls_password + char(ll_asc1 - 2)
next
CASE ELSE
messagebox("提示","用法错误,Z为加密,U为解密!")
return ""
END CHOOSE
return ls_password
我的SA密码放在ini文件中,先加密明文,然后写回ini文件,就成了乱码了,以后每次都可以调用函数解密,连接数据库了