导航:首页 > 文件教程 > delphibase64文件

delphibase64文件

发布时间:2021-03-04 04:00:45

A. Delphi中如何进行BASE64解码

delphi 中有个来EncdDecd类,这个是delphi自带的源base64编码类,里面提供了编码和解码函数分别是:
function EncodeString(const Input: string): string; //编码
function DecodeString(const Input: string): string; //解码

B. delphi7中调用webservice接收到base64编码的字节数组,如何进行解码

用函数DecodeString,需要引用 EncdDecd

C. delphi 与 c# 转 base64 结果不同

我也遇到这个问题。现在解决了,是base64的encode的问题:回
public static string DecodeBase64(string code, string encodeName)
{
string decode = "";
byte[] bytes = Convert.FromBase64String(code);
try
{
decode = Encoding.GetEncoding(encodeName).GetString(bytes);
}
catch
{
decode = code;
}
return decode;
}

string s2 = DecodeBase64(base编码答的内容, "GB2312");

D. base64再次加密用什么 delphi

delphi自带了复,use EncdDecd之后 对流制的编解码: procere EncodeStream(Input, Output: TStream); // 编码 procere DecodeStream(Input, Output: TStream); // 解码 // 对字符串的编解码: function EncodeString(const Input: string)

E. delphi java 有没有能相互base64编码的方法啊

base64都是标准的编码方式,是通用的。

Delphi、java各自用自己的函数进行编码,是可以相互进行解析的。

F. delphi2007中间的indy控件里面base64编码器没有了DecodeToStream函数怎么办

Delphi 2007 的Indy 版本是Indy 10
Delphi 7 自带的Indy是 Indy 9

G. 如何在delphi中实现对文件进行base64编码

TBase64=Class(TObject)
private
FOStream:TStream;
FIStream:TStream;
Public
{输入流}
PropertyIStream:;
{输出流}
PropertyOStream:;
{编码}
FunctionEncode:Boolean;
{解码}
FunctionDecode:Boolean;
End;

implementation

const
SBase64:string='~#%&*+-';
UnBase64:array[0..255]ofbyte=
(128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,//0-15
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,//16-31
128,128,128,58,128,59,60,128,128,128,61,62,128,63,128,128,//32-47
128,128,0,1,2,3,4,5,6,7,128,128,128,128,128,128,//48-63
128,8,9,10,11,12,13,14,15,128,16,17,18,19,20,128,//64-79
21,22,23,24,25,26,27,28,29,30,31,128,128,128,128,128,//80-95
128,32,33,34,35,36,37,38,39,40,41,42,128,43,44,45,//96-111
46,47,48,49,50,51,52,53,54,55,56,128,128,128,57,128,//112-127
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,//128-143
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,//128-143
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,//144-159
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,//160-175
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,//176-191
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,//192-207
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,//208-223
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,//224-239
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128);//240-255
{TBase64}

functionTBase64.Decode:Boolean;
var
j,k:integer;
b:byte;
W,Tmp:Byte;//用于阅读流的临时变量
begin
Result:=FALSE;
If(FIStream<>Nil)And(FOStream<>Nil)Then
Begin
{初始化}
IStream.Position:=0;
OStream.Position:=0;
b:=0;
j:=0;
K:=2;
while(IStream.Position<IStream.Size)And(IStream.Read(Tmp,1)=1)And(Char(Tmp)<>'.')Do
Begin
ifj=0then
begin
b:=UnBase64[Tmp];
k:=2;
end
elsebegin
W:=UnBase64[Tmp]or((bshlk)and$C0);
OStream.Write(W,1);
inc(k,2);
end;
inc(j);
j:=jand3;
end;
End;
end;

functionTBase64.Encode:Boolean;
var
SBuffer:Array[1..4]OfByte;
j,k:integer;
b:byte;
Tmp:Byte;{###用于阅读流的临时变量###}
begin
Result:=FALSE;
If(FIStream<>Nil)And(FOStream<>Nil)Then
Begin
{初始化}
IStream.Position:=0;
OStream.Position:=0;
b:=0;j:=2;k:=2;
whileIStream.Position<IStream.Sizedo
begin
IfIStream.Read(Tmp,1)=1Then
Begin
b:=bor((Tmpand$C0)shrk);
inc(k,2);
SBuffer[j]:=Byte(SBase64[(TmpAnd$3F)+1]);
inc(j);
ifj>4then
begin
SBuffer[1]:=Byte(SBase64[b+1]);
b:=0;
j:=2;
k:=2;
OStream.Write(SBuffer,4);
End;
End;
End;

{平整数据到SBuffer}
ifj<>2then
begin
SBuffer[j]:=Ord('.');
SBuffer[1]:=Byte(SBase64[b+1]);
OStream.Write(SBuffer,j);
end
elseBegin
SBuffer[1]:=Ord('.');
OStream.Write(SBuffer,1);
end;
Result:=TRUE;
end;
end;
//--------------------------------------------------------------
翻译成C++的:
classTBase64:publicTObject{
private:
TSreamFOStream;
TStreamFIStream;
public:
//输入流
__propertyTStreamIStream={read=FIStream,write=FIStream};
//输出流
__propertyTStreamOStream={read=FOStream,write=FOStream};
//编码
boolEncode();
//解码
boolDecode();
};

constchar*SBase64="~#%&*+-";
constunsignedcharUnBase64[256]={
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,//0-15
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,//16-31
128,128,128,58,128,59,60,128,128,128,61,62,128,63,128,128,//32-47
128,128,0,1,2,3,4,5,6,7,128,128,128,128,128,128,//48-63
128,8,9,10,11,12,13,14,15,128,16,17,18,19,20,128,//64-79
21,22,23,24,25,26,27,28,29,30,31,128,128,128,128,128,//80-95
128,32,33,34,35,36,37,38,39,40,41,42,128,43,44,45,//96-111
46,47,48,49,50,51,52,53,54,55,56,128,128,128,57,128,//112-127
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,//128-143
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,//128-143
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,//144-159
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,//160-175
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,//176-191
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,//192-207
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,//208-223
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,//224-239
128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128};//240-255
boolTBase64::Decode()
{
intj,k;
unsignedcharb;
unsignedcharW,Tmp;
boolResult=false;
if(FIStream!=NULL&&FOStream!=NULL)
{
//初始化
IStreamPosition=0;
OStreamPosition=0;
b=0;
j=0;
K=2;
while(IStream.Position<IStream.Size&&(IStream.Read(Tmp,1)==1)&&((char)Tmp)!='.')
{
if(j==0)
{
b=UnBase64[Tmp];
k=2;
}
else
{
W=UnBase64[Tmp]|((b>>k)&0xC0);
OStream.Write(W,1);
k+=2;
}
j++;
j&=3;
}
}
returnResult;
}

boolTBase64::Encode()
{
unsignedcharSBuffer[4];
intj,k;
unsignedcharb,Tmp;//用于阅读流的临时变量
boolResult=false;
If(FIStream!=NULL&&FOStream!=NULL)
{
//初始化
IStream.Position=0;
OStream.Position=0;
b=0;
j=2;
k=2;
while(IStream.Position<IStream.Size)
{
If(IStream.Read(Tmp,1)==1)
{
b=b|((Tmp&0xC0)<<k);
k+=2;
SBuffer[j]=(unsignedcahr)(SBase64[(Tmp&0x3f)+1]);
j++;
if(j>4)
{
SBuffer[0]=Byte(SBase64[b]);
b=0;
j=2;
k=2;
OStream.Write(SBuffer,4);
}
}
}
//平整数据到SBuffer
if(j!=2)
{
SBuffer[j]='.';
SBuffer[0]=(unsignedchar)(SBase64[b+1]);
OStream.Write(SBuffer,j);
}
else
{
SBuffer[0]='.';
OStream.Write(SBuffer,1);
}
Result=true;
}
returnResult;
}

H. 如何在delphi中实现对文件进行base64编码

delphi 中有个EncdDecd类,这个是delphi自带的base64编码类,里面提供了编码和解码函数专分别是:属
function EncodeString(const Input: string): string; //编码
function DecodeString(const Input: string): string; //解码

I. 如何在delphi中实现对文件进行base64编码

在 delphi 中,实现对文件进行 base64 编码,步骤如下:

1、下载 CnPack 组件包(CnVCL)

CnVCL 是一个涵盖不可视工具组件、界面控件、网络通讯组件、多语言处理等多个方面的 Delphi/C++ Builder 组件包

J. delphi EncodeBase64 在哪个单元

我这边是自己弄的。不知道引用哪个单元。。
Function Base64Encode(mSource:String;mAddLine:Boolean=True):String;
Var
I,J: Integer;
S: String;
Begin
Result:=' ';
J:= 0;
For I :=0 To Length(mSource) Div 3 - 1 Do
Begin
S :=Copy(mSource,I*3+1,3);
Result :=Result+cBase64[Ord(S[1]) Shr 2 + 1];
Result :=Result+cBase64[((Ord(S[1]) And $03) Shl 4) + (Ord(S[2]) Shr 4) + 1];
Result :=Result+cBase64[((Ord(S[2]) And $0F) Shl 2) + (Ord(S[3]) Shr 6) + 1];
Result :=Result+cBase64[Ord(S[3]) And $3F + 1];
If mAddLine Then
Begin
Inc(J,4);
If J>=76 Then
Begin
Result :=Result+#13#10;
J :=0;
End;
End;
End;
I :=Length(mSource) Div 3;
S :=Copy(mSource,I*3+1,3);
Case Length(S) Of
1: Begin
Result :=Result+cBase64[Ord(S[1]) Shr 2+1];
Result :=Result+cBase64[(Ord(S[1]) And $03) Shl 4+1];
Result :=Result+cBase64[65];
Result :=Result+cBase64[65];
End;
2: Begin
Result :=Result+cBase64[Ord(S[1]) Shr 2 + 1];
Result :=Result+cBase64[((Ord(S[1]) And $03) Shl 4) +(Ord(S[2]) Shr 4)+1];
Result :=Result+cBase64[(Ord(S[2]) And $0F) Shl 2 + 1];
Result :=Result+cBase64[65];
End;
End;
End; { Base64Encode }

Function Base64Decode(mCode: String): String;
Var
I, L: Integer;
S: String;
Begin
Result := ' ';
L :=Length(mCode);
I :=1;
While I<=L Do
Begin
If Pos(mCode[I],cBase64)>0 Then
Begin
S :=Copy(mCode,I,4);
If (Length(S)=4) Then
Begin
Result := Result + Chr((Pos(S[1], cBase64) -1) Shl 2 +(Pos(S[2], cBase64) -1) Shr 4);
If S[3] <> cBase64[65] Then
Begin
Result := Result + Chr(((Pos(S[2], cBase64) -1) And $0F) Shl 4 +(Pos(S[3], cBase64) -1) Shr 2);
If S[4] <> cBase64[65] Then
Result := Result + Chr(((Pos(S[3],cBase64) -1) And $03) Shl 6+(Pos(S[4], cBase64) - 1));
End;
End;
Inc(I, 4);
End
Else
Inc(I);
End;
End; { Base64Decode }

阅读全文

与delphibase64文件相关的资料

热点内容
vb编写一个简单计算器程序代码 浏览:381
app代充怎么赚钱 浏览:133
湖南省大数据发展 浏览:838
ip和数据哪个好看 浏览:409
linux文件驱动 浏览:511
超大数据中心 浏览:697
工作文件系统如何建立 浏览:307
利用文件中的内容初始化 浏览:935
马云支付宝用到的大数据技术 浏览:333
厦门大数据战略 浏览:720
6s如何设置app切换 浏览:724
西门子编程软件在官方网站哪里找 浏览:511
大数据社会调研报告 浏览:172
数据中的属性有哪些类型 浏览:176
苹果6手机支付宝加密 浏览:480
大数据的内涵以下理解 浏览:92
word2007组合 浏览:643
定向士官在什么网站报志愿填报 浏览:332
hyp是什么文件格式 浏览:720
编程哪里学靠谱 浏览:224

友情链接