【问题标题】:Mime / Base 64 encodingMime / Base 64 编码
【发布时间】:2011-04-03 14:33:46
【问题描述】:

我需要一种在 Delphi 7 和 PHP 中将字符串编码为 Mime/Base64 的方法

这两个编码器必须兼容:)

【问题讨论】:

  • 谁来编码,谁来解码?

标签: php delphi base64 mime encode


【解决方案1】:

单元 EncdDecd 从 Delphi 6 开始就被包含在内;下面是它包含的 Mime 兼容的 base64 函数。

这个cached post from FlexVNoriginal post 并不总是在线)解释了如何使用 EncdDecd 单元在 PHP 和 Delphi 之间进行 base64 处理。

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】:

    Indy-Project 提供 base64 编码器/解码器类。您可以找到文档here

    对于 PHP,您可以使用 PHP 内部函数 base64_encodebase64_decode

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-30
      • 1970-01-01
      • 2011-10-11
      • 1970-01-01
      • 2018-09-01
      • 2012-12-15
      相关资源
      最近更新 更多