php encryption thats unencryptable in delphi

I think the question title says it all.   I need to encrypt something in PHP that can be unencrypted in delphi.  Any ideas?

LVL 1
hibbidijiAsked:
Who is Participating?
 
Eddie ShipmanAll-around developerCommented:
in the PHP code above, $encrypted_data is a STRING.

Here is docs on the mcrypt_encrypt PHP function:

mcrypt_encrypt -- Encrypts plaintext with given parameters

Description
string mcrypt_encrypt ( string cipher, string key, string data, string mode [, string iv] )

mcrypt_encrypt() encrypts the data and returns the encrypted data.

Cipher is one of the MCRYPT_ciphername constants of the name of the algorithm as string.
{DES, TripleDES, Blowfish (default), 3-WAY, SAFER-SK64, SAFER-SK128, TWOFISH, TEA, RC2,
 GOST in CBC, OFB, CFB and ECB; see http://www.php.net/manual/en/ref.mcrypt.php for the
string constants to use}

Key is the key with which the data will be encrypted. If it's smaller that the required keysize,
it is padded with '\0'. It is better not to use ASCII strings for keys. It is recommended to use
the mhash functions to create a key from a string.

Data is the data that will be encrypted with the given cipher and mode. If the size of the data
is not n * blocksize, the data will be padded with '\0'. The returned crypttext can be larger
that the size of the data that is given by data.

Mode is one of the MCRYPT_MODE_modename constants of one of "ecb", "cbc", "cfb", "ofb",
"nofb" or "stream".

The IV parameter is used for the initialisation in CBC, CFB, OFB modes, and in some algorithms
in STREAM mode. If you do not supply an IV, while it is needed for an algorithm, the function
issues a warning and uses an IV with all bytes set to '\0'.

You can use PHP to do this from your Delphi application using PHP4Delphi. However, you must have
libmcrypt installed also. Look at the accepted answer here:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_21056045.html


0
 
mikelittlewoodCommented:
What are you trying to encrypt in PHP?
As long as you stick to the same encryption method within both PHP and Delphi I wouldnt have thought there would be an issue.
0
 
BlackTigerXCommented:
as mikelittlewood says, if you provide the method you are using to encrypt in PHP, some one can come up with an algorithm to decrypt or point out some resources of already built solutions for such algorithm
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
Eddie ShipmanAll-around developerCommented:
He must be talking about the PHP crypt function.

crypt -- One-way string encryption (hashing)

crypt() will return an encrypted string using the standard Unix DES-based
encryption algorithm or alternative algorithms that may be available on the system.

No way to decrypt it, however. It is a one-way hash like MD5.
0
 
Eddie ShipmanAll-around developerCommented:
I think the OP needs to further define his requirements.
0
 
hibbidijiAuthor Commented:
Pardon me folks.   I will write a code example of how i USUALLY encrypt in php.

$data = $datatemp;
$key = "keyhere";
$td = MCRYPT_RIJNDAEL_256;

$encrypted_data = @mcrypt_encrypt($td, $key, $data, MCRYPT_MODE_CBC);


This has its disadvantages.   Here is my application:

Delphi 2005 applicaiton  reads encrypted database from web server and writes an encrypted temp file to disc.   App decrypts it at runtime in memory, leaving the temp file encrypted for mild security.   (I know that people can do memory dumps and get my db, its not THAT important, just mild encryption or obfuscation is needed)

The downsides with my above example are that it requires either mcrypt or similar bloat to the delphi app, and that it generates a binary file that is not as easily transferred with http over the net.   I can happily zip the file for transfer (I have a zip componenet for delphi) or use FTP if you folks think my existing idea is best.   Just looking for options.  Thanks!


0
 
hibbidijiAuthor Commented:
Further clarification:

Database is > 500k & <20mb

0
 
hibbidijiAuthor Commented:
I've contacted the author of dcpcrypt and have a solution.

0
 
Eddie ShipmanAll-around developerCommented:
Could you post the solution here for everyone?
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.