Crypto API


I am looking for a simple Encrypt/Decrypt function to encrypt and decrypt a string in Delphi using some type of a key. I want to use a program to be able to encrypt a string on one computer and then using the same program on another computer I want decrypt it. I would like to use Crypto API and as far as I gathered all the Crypto API function sits in the Crypt32.dll?

The key will be hardcode in the EXE. The reason why I thought about using a key to encrypt/decrypt the data is because there should be no installation needed. I want to be able to send to EXE to person X and then he should be able to decrypt the data.

Can anyone help me find a suitable solution?
Who is Participating?
MerijnBConnect With a Mentor Sr. Software EngineerCommented:
This open source library can handle most well known encryption mechanisms:
You'll won't be depended of any external libraries (Crypt32.dll).
You can use LockBox components.

Simple sample:

  LbCipher, LbString;

  cKey: TKey128 = (23,56,21,83,254,123,176,39, 239,2,19,47,146,192,234,152);

function Encrypt(const pInString: String): String;
  result := BFEncryptStringEx(pInString,cKey,true);

function Decrypt(const pInString: String;
                   var pOutString: String): Boolean;
    pOutString := BFEncryptStringEx(pInString,cKey,false);
    result := true;
    result := false;
LockBox components can be download from:

Unfortunatelly it was written for older delphi versions, so if you will have problems with installation on D2007 then I can give you my package :).
Ruan1618Author Commented:
Thanks for the reply! :) It was very useful all though the problem is that I need to implement this in C# as well as Delphi. The reason for this is that we would like to start using encryption in our current programs and we have programs in Delphi and C#. This is why I am looking for encryption methods that forms part of windows and not something that is included as part of our program. That is the reason why Im would like to use crypto32.dll. I have also found that advapi32.dll also contains encryption methods that can be used in Delphi and C#. So I am looking for good methods to use in crypto32.dll or advapi.dll that uses a public/private key or something similar.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.