0

I have to decrypt string in PHP, which is being generated from Java class. And I am not able to understand what exactly is being done in that class. Java class used for encryption-decryption

Can someone suggest me the equivalent code or process to decrypt the encrypted string.

Maximin
  • 1,655
  • 1
  • 14
  • 32
Nehrav
  • 41
  • 1
  • 8
  • possible duplicate of [Decrypt ( with PHP ) a Java encryption ( PBEWithMD5AndDES )](http://stackoverflow.com/questions/10300185/decrypt-with-php-a-java-encryption-pbewithmd5anddes) – VolkerK Mar 11 '13 at 08:42
  • i think you need to study decre in the same class lia.. – Bhavin Rana Mar 11 '13 at 08:43

3 Answers3

2

that Java class seems to do a DES encryption.

In PHP you can do:

$result=mcrypt_decrypt ( "MCRYPT_DES" , $key , $data , $mode);

The $key and $mode variables are information you should know, $data is the input encrypted string. You may want to try MCRYPT_3DES if the other one doesn't work.

Naryl
  • 1,878
  • 1
  • 10
  • 12
  • Already tried above example but not getting desired result. Secondly, can some one explain what is being done in that class (step by step). – Nehrav Mar 11 '13 at 10:19
0

Well, if even you don't seem to know, which encryption algorithm is used, it's hard for us to help you. I'm not familiar with the code and the classes which are used there but it seems that DES is used (no shit) in a weird combination with Base64. Search for DES decryption with PHP, also PHP has functions for handling Base64-String.

You can also search for what SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(keySpec); does.

Joshua
  • 2,932
  • 2
  • 24
  • 40
0

The code you linked generates an encryption key using a salt, passphrase and the number of md5 iterations.

With the encryption key you can encrypt / decrypt.

A couple of years ago I implemented a php version of the used algorithm PBEWithMD5AndDES: https://github.com/kevinsandow/PBEWithMD5AndDES

Kevin Sandow
  • 4,003
  • 1
  • 20
  • 33