首页 > 编程知识 正文

base64解码 百度网盘,base64编码有什么用

时间:2023-05-04 08:50:57 阅读:17467 作者:4792

由于业务需要,调用服务端接口返回的内容是加密的。 加密过程是base64.encode(zip压缩) xml明文)。 解码的流程是base64.decode(zip解压缩(UTF-8转码) ) ) )

其中的ZIP压缩实际上是GZip压缩,两者的压缩方式略有不同,Delphi需要在解压缩时采用不同的方法处理。

通过查找各种资料,最终确定了在zipLibEx源包中搜索的几种用法可以解压缩gZip。 由于业务需要,本文还包括base64加密、utf-8转码的操作技巧。

加密文本:

H4 siaaaaaaaeahwoswcmbce/0 RTU7zaipkucuarlww0gumjgerdajrkov 58 l8fjxnpofjpzwr 58 uha 96 ufqmn7h1 ppivpevutb 93 ceny7la4kdwq6zylfvxgwzzzzszszssszwr bkzysglfkleywl 3i yaca7kahno 97 gducikw/pyeeupmeacey 6y 5m 229 mmj3TJ9tojpfjxecwovlnyfef5czjhpaaaa=

明文解密:

'? XML版本=' 1.0 '编码=' utf-8 '? response _ common _ dycom cs class=' response _ common _ dycom cs ' dyxxsdyxx……cwdm 0000/cwdmcwxx5OMT5y2 w5 oiq5yqf/cwxxx

使用usesSoap.EncdDecd{base64解密},使用ZLibEx{gZip解压缩}

//Gzip解压缩函数封装,感谢zydjmg的代码proceduredecompressgzip (ain stream,AOutStream: TStream ) ); var pb1、Pb 2:字节; beginainstream.seek (1,0 ); ain stream.read (PB1,1 ); ain stream.seek (2,0 ); ain stream.read (Pb2,1 ); AInStream.Position :=0; AOutStream.Position :=0; if(Pb1=$8b ) and ) Pb2=$8) then //$8B和$8压缩zdecompresstream2(ainstream,AOutStream,47 ) /进行gzip解压缩elseaouttttttttttor functiondecodegziputf 8字符串(input : pchar; vara outstr : widestring (:蓝牙; stdcall; var InStr,OutStr: TStringStream; stream,out_stream: TStringStream; destr :字符串; begin Result :=False; //解压缩方法使用流处理,因此这里全部在TStringStream中操作instr :=tstring stream.create (input )。 stream :=tstring stream.create; out _ stream :=tstring stream.create; outstr :=tstring stream.create (' ); trydecodestream(Instr,OutStr ); //首先,base64解码DecompressGzip(Outstr,stream ); //out _ stream 3360=tstring stream.create (',TEncoding.UTF8 ); out _ stream.loadfromstream (stream; //再UTF-8转码destr :=out _ stream.datastring; //读取流数据AOutStr :=deStr; result :=真; finallyfreeandnil(Outstr; Freeandnil(Instr ); freeandnil (流; freeandnil(out_stream; 结束; 结束; 调用方法:

function tform2. decodegziputf 8str (输入:字符串) :字符串; var DecodeStr: WideString; begin Result :=' '; decodegziputf 8字符串(pchar (输入)、DecodeStr ); 结果:=decodestr; 结束;

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。