Solved

RC4 encryption in delphi 7

Posted on 2008-06-10
2
3,112 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Explore the encryption capabilities built into Google Apps and how these features can help you meet privacy policy and regulatory compliance, but are not a full solution. Understand and compare the most popular email encryption services for Google A…
When the confidentiality and security of your data is a must, trust the highly encrypted cloud fax portfolio used by 12 million businesses worldwide, including nearly half of the Fortune 500.
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…
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 …

735 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