Base64编码到底是什么东东,哪里有它的 编码和解码的源代码,哪位大虾能透露一下
解决方案 »
- Time 问题
- 窗口如何时关闭
- 没有天理了! d7 中去掉了支持 Corba, 也没有提供一个好的替代方案.最厌恶的就是 那些 DComConnection 之流基于 com/dcom 的 落后东西.
- 请问哪里有DELPHI 3 下载
- Delphi对于BTR数据库文件的访问有没有参考资料提供?
- delphi 登录Discuz论坛问题
- 我很笨,大家帮了我.而我却不知如何结帖.告诉我-给分??
- 有哪位知道怎么检测打印机打开没有。
- 请问各位大虾,dxdbgrid怎样读取每一组的统计值,非常紧急,在线等!!!
- 一只菜鸟的问题
- 制作后台数据库是SQL SERVER的安装程序时,怎么样能让安装程序自动注册数据库?
- 大侠请看,关于在程序中调用帮助的问题!
const
BaseTable = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; 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; 在SMTP.OnConnect事件中写身份验证.
procedure TSendFile.NMSMTPConnect(Sender: TObject);
begin {身份验证}
if FSMTP.ReplyNumber = 250 then
FSMTP.Transaction('auth login');
if FSMTP.ReplyNumber = 334 then
begin
FSMTP.Transaction(EncodeBase64(FUserID));
FSMTP.Transaction(EncodeBase64(FPassword));
end;
end;