二进制转 Base64 (Delphi) [英] Binary to Base64 (Delphi)
本文介绍了二进制转 Base64 (Delphi)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取 exe
文件的内容并将其转换为 Base64
编码?
How can I get content of an exe
file and convert it into Base64
encoding ?
编辑
我使用 D2010
,我想知道这到底是怎么可能的?
I use D2010
and I want to know how is it possible exactly ?
打开一个exe文件
将其内容转为base64
推荐答案
在 Delphi 2009/2010/XE 中有单元 EncdDecd.pas
(Soap.EncdDecd.pas
对于 Delphi XE2) 包含函数 EncodeBase64
和 DecodeBase64
.您可以将 exe 文件加载到内存流中,然后调用 EncodeBase64.
In Delphi 2009/2010/XE there is unit EncdDecd.pas
(Soap.EncdDecd.pas
for Delphi XE2) containing the functions EncodeBase64
and DecodeBase64
. You can load the exe file into a memorystream and then call EncodeBase64.
function EncodeFile(const FileName: string): AnsiString;
var
stream: TMemoryStream;
begin
stream := TMemoryStream.Create;
try
stream.LoadFromFile(Filename);
result := EncodeBase64(stream.Memory, stream.Size);
finally
stream.Free;
end;
end;
这篇关于二进制转 Base64 (Delphi)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文