Re: [Bcrypt-users] Bcrypt and PHP
Status: Beta
Brought to you by:
jwshelley
From: <jsh...@br...> - 2008-08-08 16:11:28
|
Howdy, My memory is really rusty on this, but there is some header information on top of the data that specifies endianness and a few other things that you'd have to have. Also, you may need to pass some extra flags to mcrypt to force it to use the same blocksize etc. You'll need to dig through the source a bit and see all the steps that go into creating a file and follow them, or you'll never get the two methods to play nice. Glad you've been enjoying bcrypt. Someday perhaps we'll get a new version that incorporates everyone's feature requests. johnny Quoting Brett Scott <Bre...@gr...>: > Hello again. > > I've started looking into a different way to encrypt a file (blowfish) > and then send it to a server that uses bcrypt.exe to decrypt it, without > requiring bcrypt.exe to do the initial encryption. > > As the initial data is captured in a PHP script, we're looking at > encrypting the data in PHP, sending it to the remote server, where > bcrypt.exe is used to decrypt. > > The following PHP script failed to work. Here is the steps I took. > > 1. Execute the below PHP script which will create the encrypted file > 'test1.txt.bfe' with the contents '1234567890' based on the key > 'eggheads'. > 2. PHP script creates the blowfish encrypted file 'test1.txt.bfe' > 3. Execute 'bcrypt test1.txt.bfe' (to unencrypt the file) > 4. Enter the password 'eggheads' into the command line > 5. Warning 'Invalid encryption key for file ...' message received > > <?php > > $key = 'eggheads'; > $filename = 'test1.txt.bfe'; > $string = '1234567890'; > > $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_BLOWFISH, > MCRYPT_MODE_CBC), MCRYPT_RAND); > $encrypted_string = mcrypt_encrypt(MCRYPT_BLOWFISH, $key, $string, > MCRYPT_MODE_CBC, $iv); > > $fp = fopen($filename, 'w'); > fwrite($fp, $encrypted_string); > fclose($fp); > > // 1. To test decryption of file with bcrypt, execute 'bcrypt > test1.txt.bfe' > // 2. Prompted for password, enter 'eggheads' > // 3. File 'test1.txt' will appear in file system > > ?> > > QUESTION. > You may not have knowledge with PHP but is there something obvious I'm > missing here? Is it something to do with the IV or MODE (CBC/ECB)? > > Thank you :) > Brett. > |