delphi webservices 字节数组 Base64编码


本文整理自网络,侵删。

 //delphi webservices 字节数组 Base64编码

unit EncodingUtil;

interface

uses
SysUtils, Classes, Types, EncdDecd;

function BytesToBase64(const bytes : TByteArray) : string;
function StreamToBase64(AStream: TStream) : string;

implementation

function BytesToBase64(const bytes : TByteArray) : string;
var
memoryStream : TMemoryStream;
begin
memoryStream := TMemoryStream.Create;
memoryStream.WriteBuffer(bytes[0], Length(bytes));
memoryStream.Seek(0, soFromBeginning);
Result := StreamToBase64(memoryStream);
memoryStream.Free;
end;


function StreamToBase64(AStream: TStream) : string;
var
objSS: TStringStream;
begin
objSS := TStringStream.Create('');
try
EncodeStream(AStream, objSS); //Delphi7 自带unit EncdDecd的方法
Result := objSS.DataString;
finally
FreeAndNil(objSS);
end;
end;

相关阅读 >>

Delphi删除只读文件

Delphi产生不重复随机数的算法

Delphi遍历进程并获取进程路径

Delphi 下找到目录中的所有文件夹

Delphi分离汉字和英文字母

Delphi编程实现图像的淡入浅出

Delphi datetimepicker 宽度如何与Delphi自带style同步

Delphi cb_addstring 与lb_addstring的区别?

Delphi tfdmemtable 更新到数据库

Delphi图像二值化

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...