1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
function RDLEncryptStringEx(const InString : string;
const Key; KeySize : Longint; Encrypt : Boolean) : string;
var
InStream : TMemoryStream;
OutStream : TMemoryStream;
WorkStream : TMemoryStream;
begin
InStream := TMemoryStream.Create;
OutStream := TMemoryStream.Create;
WorkStream := TMemoryStream.Create;
InStream.Write(InString[1], Length(InString));
InStream.Position := 0;
if Encrypt then begin
RDLEncryptStream(InStream, WorkStream, Key, KeySize, True);
WorkStream.Position := 0;
LbEncodeBase64(WorkStream, OutStream);
end else begin
LbDecodeBase64(InStream, WorkStream);
WorkStream.Position := 0;
RDLEncryptStream(WorkStream, OutStream, Key, KeySize, False);
end;
OutStream.Position := 0;
SetLength(Result, OutStream.Size);
OutStream.Read(Result[1], OutStream.Size);
InStream.Free;
OutStream.Free;
WorkStream.Free;
end; |
Partager