Function compressstrtobase64 (SSTR: string): string;
VaR
M1: tmemorystream;
M0, M2: tstringstream;
Begin
Result: = '';
If SSTR = ''then
Exit;
M0: = tstringstream. Create (SSTR );
M1: = tmemorystream. Create;
M2: = tstringstream. Create ('');
Try
M0.position: = 0;
M1.position: = 0;
Zcompressstream (M0, M1 );
M1.position: = 0;
M2.position: = 0;
Encodestream (M1, M2 );
Result: = m2.datastring;
Finally
Freeandnil (M0 );
Freeandnil (M1 );
Freeandnil (m2 );
End;
End;
Function decompressbase64tostr (SSTR: string): string;
VaR
M0, M1: tstringstream;
M2: tmemorystream;
Begin
Result: = '';
If SSTR = ''then
Exit;
M0: = tstringstream. Create ('');
M1: = tstringstream. Create (SSTR );
M2: = tmemorystream. Create;
Try
M1.position: = 0;
M2.position: = 0;
Decodestream (M1, M2 );
M0.position: = 0;
M2.position: = 0;
Zdecompressstream (M2, M0 );
Result: = m0.datastring;
Finally
Freeandnil (M0 );
Freeandnil (m2 );
Freeandnil (M1 );
End;
End;