Crypto API

Posted on 2009-02-11
Last Modified: 2013-11-23

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?
Question by:Ruan1618
    LVL 4

    Expert Comment

    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 :).
    LVL 19

    Accepted Solution

    This open source library can handle most well known encryption mechanisms:
    You'll won't be depended of any external libraries (Crypt32.dll).

    Author Comment

    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

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    If you are on a Windows computer and decide to protect a file with sensitive data, you can encrypt the file, password protect it or rely on steganography (hiding a file in an image). This technique is especially useful because unless someone knows t…
    You cannot be 100% sure that you can protect your organization against crypto ransomware but you can lower down the risk and impact of the infection.
    The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
    The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

    728 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

    20 Experts available now in Live!

    Get 1:1 Help Now