
13.02.2016, 18:11
|
 |
Исполняемый Ретровирус
|
|
Регистрация: 09.08.2008
Адрес: Umbrella Corporation
Сообщения: 743
Репутация: 1293
|
|
Код:
(*********************************************************************
How to use:
var
s: string;
begin
s := 'Carlos Alberto Longen';
s := Crypt(s,12345);
ShowMessage(Format('Ciphered: %s', [s]));
ShowMessage(Format('Deciphered: %s', [decrypt(s,12345)]));
*********************************************************************)
unit untCrypt;
interface
// ciphers the string "strText" with 32-bit "code" "intCode"
function Crypt(const strText: string; const intKey: longint): string;
// deciphers the string "strText" with 32-bit "code" "intCode"
function Decrypt(const strText: string; const intKey: longint): string;
const
// "default key" - select a "standard" for you...
intDefKey = -967283;
implementation
// ciphers the string "strText" with 32-bit "code" "intCode"
function Crypt(const strText: string; const intKey: longint): string;
var
i: integer;
strResult: string;
begin
// initialize result
strResult := strText;
// sync RandSeed key to generate Random chars
RandSeed := intKey;
// cipher
for i := 1 to Length(strText) do
strResult[i] := Chr(Ord(strResult[i]) xor Random(255));
// set results
Crypt := strResult;
end;
// deciphers the string "strText" with 32-bit "code" "intCode"
function Decrypt(const strText: string; const intKey: longint): string;
begin
// deciphers the string
Decrypt := Crypt(strText, intKey);
end;
end.
|