呵呵,Delphi6不是自带了Base64的编码解码单元吗?单元名称叫:EncdDecd.pas,你自己打开看吧!
解决方案 »
- adoquery 下移一个记录的问题,帮我解决下别拖到明年啊!
- 这个sql语句怎么写啊
- 请问用delphi7如何获得电脑在断网状态下的mac
- 出错:multiple records found,but only one was expected.什么意思啊?谢谢!
- 高分请教ActiveX控件技术,DLL技术以及COM技术三者之间的联系及区别!!谢谢各位专家!!
- delphi6 中ppReport 打印的时候如何让其不出现预览界面而是直接打印?哪位大哥能帮忙解决一下?多谢!
- 数据库的问题
- 请问如何在设计时建立控件数组?
- 3.请问我安.dpk的包了,不过安到哪里了呢?什么也没看到,就安完了。??
- :如何用SQL语句查ACCESS中是否存在某个表?
- 快捷键的问题?
- 关于组件的问题,能者进
DecodeString()函数来解码?
procedure DecodeStream(Input, Output: TStream);
function EncodeString(const Input: string): string;
function DecodeString(const Input: string): string;
Deststring:string;
begin
……
id1base64.CodeString(Source);
DestString:=id1base64.CompletedInput;
//下面是目标字符
Delete(DestString, 1, 2);
……
end;
我在uses中加了EncdDecd
在button按钮的click事件中加了
var
need,outstring:string;
begin
need:='MzcxMTI5MTYxMcTfz/7R4A0KDQoNCg0K';
outstring:=EncodeString(need);
end
然后查看outstring变量时他的值为空,为什么?
const
BaseTable:string='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';function FindInTable(CSource:char):integer;
begin
result:=Pos(string(CSource),BaseTable)-1;
end;//解码
function DecodeBase64(Source:string):string;
var
SrcLen,Times,i:integer;
x1,x2,x3,x4,xt:byte;
begin
result:='';
SrcLen:=Length(Source);
Times:=SrcLen div 4;
for i:=0 to Times-1 do
begin
x1:=FindInTable(Source[1+i*4]);
x2:=FindInTable(Source[2+i*4]);
x3:=FindInTable(Source[3+i*4]);
x4:=FindInTable(Source[4+i*4]);
x1:=x1 shl 2;
xt:=x2 shr 4;
x1:=x1 or xt;
x2:=x2 shl 4;
result:=result+chr(x1);
if x3= 64 then break;
xt:=x3 shr 2;
x2:=x2 or xt;
x3:=x3 shl 6;
result:=result+chr(x2);
if x4=64 then break;
x3:=x3 or x4;
result:=result+chr(x3);
end;
end;
//编码
function EncodeBase64(Source:string):string;
var
Times,LenSrc,i:integer;
x1,x2,x3,x4:char;
xt:byte;
begin
result:='';
LenSrc:=length(Source);
if LenSrc mod 3 =0 then Times:=LenSrc div 3
else Times:=LenSrc div 3 + 1;
for i:=0 to times-1 do
begin
if LenSrc >= (3+i*3) then
begin
x1:=BaseTable[(ord(Source[1+i*3]) shr 2)+1];
xt:=(ord(Source[1+i*3]) shl 4) and 48;
xt:=xt or (ord(Source[2+i*3]) shr 4);
x2:=BaseTable[xt+1];
xt:=(Ord(Source[2+i*3]) shl 2) and 60;
xt:=xt or (ord(Source[3+i*3]) shr 6);
x3:=BaseTable[xt+1];
xt:=(ord(Source[3+i*3]) and 63);
x4:=BaseTable[xt+1];
end
else if LenSrc>=(2+i*3) then
begin
x1:=BaseTable[(ord(Source[1+i*3]) shr 2)+1];
xt:=(ord(Source[1+i*3]) shl 4) and 48;
xt:=xt or (ord(Source[2+i*3]) shr 4);
x2:=BaseTable[xt+1];
xt:=(ord(Source[2+i*3]) shl 2) and 60;
x3:=BaseTable[xt+1];
x4:='=';
end else
begin
x1:=BaseTable[(ord(Source[1+i*3]) shr 2)+1];
xt:=(ord(Source[1+i*3]) shl 4) and 48;
x2:=BaseTable[xt+1];
x3:='=';
x4:='=';
end;
result:=result+x1+x2+x3+x4;
end;
end;
不知道用什么方法可以看到中文?