Mime / Base 64 encoding

余生颓废 提交于 2019-12-13 02:21:27

问题


I need a way to encode a string to Mime/Base64 in Delphi 7 and PHP

These two encoders must be compatible :)


回答1:


The unit EncdDecd has been included since Delphi 6; below are the Mime compatible base64 functions it contains.

This cached post from FlexVN (the original post is not always on-line) explains how to do the base64 thing between PHP and Delphi using the EncdDecd unit.

unit EncdDecd;

interface

uses Classes, SysUtils;

procedure EncodeStream(Input, Output: TStream);
procedure DecodeStream(Input, Output: TStream);
function  EncodeString(const Input: string): string;
function  DecodeString(const Input: string): string;

function  DecodeBase64(const Input: AnsiString): TBytes;
function  EncodeBase64(const Input: Pointer; Size: Integer): AnsiString;



回答2:


The Indy-Project provides base64 encoder/decoder classes. You can find the documentation here.

For PHP, you can use the PHP-internal functions base64_encode and base64_decode.



来源:https://stackoverflow.com/questions/3564082/mime-base-64-encoding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!