導航:首頁 > 文件教程 > 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文件相關的資料

熱點內容
網站 小電影 瀏覽:122
神社代碼怎麼用 瀏覽:664
陽光下向日葵微信頭像 瀏覽:361
word編程怎麼弄 瀏覽:621
求可以看的網址 瀏覽:652
什麼語言適合工具型應用開發 瀏覽:687
大數據存儲平台 瀏覽:525
電影字幕文件轉換pdf文件 瀏覽:637
免費看片在線觀看的網站 瀏覽:713
最新能看的看片網站 瀏覽:112
iphone怎麼看種子文件 瀏覽:956
韓國電影李彩譚 瀏覽:897
手機快速傳輸文件 瀏覽:647
sql2008資料庫沒有日誌文件 瀏覽:36
有沒有直接看的網站給一個 瀏覽:19
iphone4沒聲音 瀏覽:221
exe專殺工具 瀏覽:793
macword加頁 瀏覽:516
昆明員工文件櫃多少錢一個 瀏覽:824
北京視通信元網路技術有限公司 瀏覽:363

友情鏈接