Crypto API

Hi,

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?
Ruan1618Asked:
Who is Participating?
 
MerijnBConnect With a Mentor Sr. 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).
0
 
dprochownikCommented:
You can use LockBox components.

Simple sample:

uses
  LbCipher, LbString;

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

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

function Decrypt(const pInString: String;
                   var pOutString: String): Boolean;
begin
  try
    pOutString := BFEncryptStringEx(pInString,cKey,false);
    result := true;
  except
    result := false;
  end;
end;
LockBox components can be download from:
http://sourceforge.net/projects/tplockbox/

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 :).
0
 
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.
0
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.