Oops, BASE64 shoud be implemented as on option (escaping from BIN to TEXT) of encoder (BASEing before asking password) not a sepatare pass (after asking).
Anyway, here are both (Enc/Dec)oders for BASE64: ====================== procedure Base64Decode(const s:string; const ostream:tstream; const base64mode: TBase64DecodingMode = bdmStrict); var instream: tstringstream; Decoder : TBase64DecodingStream; begin instream:= tstringstream.create(s); decoder:=TBase64DecodingStream.create(instream,base64mode); try ostream.copyfrom(Decoder,Decoder.size); ostream.Position:=0; finally Decoder.Free; instream.free; end; end; ---------------- function Base64Encode(const instream:tstream):String; var Outstream : TStringStream; Encoder : TBase64EncodingStream; begin Outstream:=TStringStream.Create(''); try Encoder:=TBase64EncodingStream.create(outstream); try Encoder.CopyFrom(instream,instream.size); finally Encoder.Free; end; Outstream.Position:=0; Result:=Outstream.ReadString(Outstream.Size); finally Outstream.free; end; end; ================ These are stream-aimed since BASE64 may encode binary data as well. 2012/7/2, IvankoB <ivankob4m...@gmail.com>: > How to decode BASE64 ? Me have "cypher not found" at : > > cbase64,crh: tsymciphercryptohandler; > [...] > crh:= tsymciphercryptohandler.create(nil); > crh.ciphername:= 'aes-256-cbc'; // default digest is MD5 > cbase64:= tsymciphercryptohandler.create(nil); > cbase64.ciphername:= 'base64'; > crh.key:= <<passw>>; > s3:= cbase64.decrypt(OU); /// <<<< HERE > s3:= crh.decrypt(s3); > > > Me need to implement decoding algo from the attached file, the CMD file > produces correct result. > > ================= > The working BASE64 decoding procedure is : > > procedure Base64Decode(const s:string; const ostream:tstream; const > base64mode: TBase64DecodingMode = bdmStrict); > var > instream: tstringstream; > Decoder : TBase64DecodingStream; > begin > instream:= tstringstream.create(s); > decoder:=TBase64DecodingStream.create(instream,base64mode); > try > ostream.copyfrom(Decoder,Decoder.size); > ostream.Position:=0; > finally > Decoder.Free; > instream.free; > end; > end; > =============== > but its result is different tan one for in-place OPENSSL base-64-option > (though BASE46 pass can be applied out of OPENSLL if urgently needed). > > PS: > 1) how can me know that AES decoding succeeds in > tstringlist.loadfromstream(encrypted tmsefilestream) - keyphrase, data > integgity etc are OK? > 2) is it correct to decode externally encoded contents, to set > "tmsefilestream.cryptohandler" AFTER loading these contents via > "tmsefilestream.copyfrom({stream},..)" ? > > sl:= tstringlist.create; > sl.loadfromstream({msefilestream}); > showmessage(sl[0]); > sl.free; ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ mseide-msegui-talk mailing list mseide-msegui-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk