Solved

RC4 encryption in delphi 7

Posted on 2008-06-10
2
3,070 Views
Last Modified: 2010-04-21
hi
i founfd this two function to encrypt and decrypt a text in delphi 7
but when i use these functions , delphi doesn't know TDCP_rc4

what can i do ?


function RC4Encrypt(Data, Key: string): string;
var Encrypted: array of byte;
    i: integer;
begin
 result := '';

 with TDCP_rc4.Create(nil) do
 try
  Init(Key[1], Length(Key) * 8, nil);
  SetLength(Encrypted, Length(Data));
  Encrypt(Data[1], Encrypted[0], Length(Data));

  for i := 0 to Length(Encrypted) - 1 do
   result := result + IntToHex(Encrypted[i], 2);

  result := LowerCase(result);
 finally
  Free();
 end;
end;


function RC4Decrypt(Data, Key: string): string;
var Encrypted: array of byte;
    i: integer;
begin
 result := '';

 with TDCP_rc4.Create(nil) do
 try
  Init(Key[1], Length(Key) * 8, nil);

  SetLength(Encrypted, Length(Data) div 2);

  for i := 0 to Length(Encrypted) - 1 do
   Encrypted[i] := StrToInt('$' + Copy(Data, (i * 2) + 1, 2));

  SetLength(result, Length(Encrypted));
  Decrypt(Encrypted[0], result[1], Length(Encrypted));
 finally
  Free();
 end;
end;


procedure TForm1.Button1Click(Sender: TObject);
var s: string;
begin
 s := RC4Encrypt('test string', '123456');
 s := RC4Decrypt(s, '123456');
end;
0
Comment
Question by:Mahsa60
2 Comments
 
LVL 19

Accepted Solution

by:
MerijnB earned 125 total points
ID: 21750116
lol, it actually looks like code from me :) Where did you find it?

It probably uses DCPcrypt: http://www.cityinthesky.co.uk/cryptography.html
0
 

Author Closing Comment

by:Mahsa60
ID: 31465667
that was Your Codes , thank you .....
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Intraweb download file link ? 1 109
ISP 1000 - Netscreen 2 49
Press three keys together and trigger a function 3 50
Can you set up BitLocker to not require PIN/KEY on boot? 1 42
As a financial services provider, your business is impacted by two of the strictest federal regulations on record: the Sarbanes-Oxley Act and the Gramm-Leach-Bliley Act. Correctly implementing faxing into your organization to provide secure, real-ti…
There are many Password Managers (PM) out there to choose from. PM's can help with your password habits and routines, but they should not be a crutch you rely on too heavily. I also have an article for company/enterprise PM's.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now