Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# RC4 encryption in delphi 7

Posted on 2008-06-10
Medium Priority
3,147 Views
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
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

LVL 19

Accepted Solution

MerijnB earned 500 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

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

## Featured Post

Question has a verified solution.

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

Healthcare providers, insurance companies and other covered entities trust eFax Corporate to transmit their most sensitive documents. eFax Corporate can help your organization implement a HIPAA compliant cloud faxing solution.
Encryption for Business Encryption (https://en.wikipedia.org/wiki/Encryption) ensures the safety of our data when sending emails. In most cases, to read an encrypted email you must enter a secret key that will enable you to decrypt the email. T…
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…
###### Suggested Courses
Course of the Month7 days, 6 hours left to enroll