我在MSN里下载了pb 的base64编码解码程序,好象有先问题
这个字符串 'C43FB772-4B68-4A43-9E87-7E4A3ABEBBAB' 编码完成后在进行解码操作以后,最后的单引号变成空格了,不知道怎么回事
------解决方案--------------------
我用的是pb9.03 8836,我记不得我后来有没有再改过,我电脑上保存的base64.pbl测试正常。
不过,我印象当中,的确是有问题,主要就是最后一位。
贴出我电脑上存的base64decode函数代码,你自己比较一下吧。
//base64解密
//参数说明:
//strbuf 待解密串
//lc_return 回写解密后字符数组
//返回解密后blob
char lch_base64key[64]
blob lbl_return
lch_base64key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
if len(strbuf) = 0 then return lbl_return
if right(strbuf,1) = '=' then
if left(right(strbuf,2),1) = '=' then
strbuf = left(strbuf,len(strbuf) - 2)
else
strbuf = left(strbuf,len(strbuf) - 1)
end if
end if
longlong ll_len,i,t,j
ll_len = len(strbuf) / 2
string m[],x
char s1[2]
long ll_loops,ll_strlen
ll_strlen = len(strbuf)
IF ll_strlen > 6000 THEN
IF Mod(ll_strlen, 6000) = 0 THEN
ll_loops = ll_strlen/6000
ELSE
ll_loops = (ll_strlen/6000) + 1
END IF
ELSE
ll_loops = 1
END IF
longlong ll_currentpos
ll_currentpos = 1
string ls_tmp
for j = 1 to ll_loops
ls_tmp = mid(strbuf,ll_currentpos,6000)
ll_currentpos += 6000
ll_len = len(ls_tmp) / 2
//转为十六进制字串
for i = 1 to ll_len
s1 = mid(ls_tmp,i*2 - 1,2)
t = (Pos(lch_base64key,s1[1]) - 1) * 64 + (Pos(lch_base64key,s1[2]) - 1)
x = int2hex(t)
if len(x) > 3 then
m[j] += right(x,3)
elseif len(x) = 2 then
m[j] += '0'+x
elseif len(x) = 1 then
m[j] += '00'+x
end if
next
next
if mod(len(ls_tmp),2)=1 then
t = (pos(lch_base64key,right(ls_tmp,1)) - 1) * 64
x = int2hex(t)
if len(x) > 3 then
m[ll_loops] += right(x,3)
elseif len(x) = 2 then
m[ll_loops] += '0'+x
elseif len(x) = 1 then
m[ll_loops] += '00'+x
end if
m[ll_loops] = left(m[ll_loops],len(m[ll_loops]) - 2)
end if
char lch_temp[]
string ls_temp
ll_currentpos = 0
for j = 1 to upperbound(m)
ll_len = len(m[j]) / 2
for i = 1 to ll_len
ls_temp = mid(m[j],i*2 - 1,2)
lch_temp[i+ll_currentpos] = char(hex2int(ls_temp))
next
ll_currentpos += len(m[j]) / 2
next
lc_return = lch_temp
lbl_return = chararray2blob(lch_temp)
//messagebox('',string(asc(lch_temp[upperbound(lch_temp)])))
return lbl_return