• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3319
  • Last Modified:

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?
1 Solution
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 :).
MerijnBSr. Software EngineerCommented:
This open source library can handle most well known encryption mechanisms: http://www.cityinthesky.co.uk/cryptography.html
You'll won't be depended of any external libraries (Crypt32.dll).
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.

Featured Post

When ransomware hits your clients, what do you do?

MSPs: Endpoint security isn’t enough to prevent ransomware.
As the impact and severity of crypto ransomware attacks has grown, Webroot fought back, not just by building a next-gen endpoint solution capable of preventing ransomware attacks but also by being a thought leader.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now