Solved

convert php encryption into java code

Posted on 2010-08-19
3
679 Views
Last Modified: 2016-03-18
A bit of background.

I have SugarCRM. My data for sugarcrm is in a progress database. Apatar can move the data. One problem though. sugarcrm requires a key. I've posted the code below. Apatar is open source, so I grabbed the regular sugarcrm template and created a sugarcrmldap template.

The encryption is where I run into a problem.  I've been trying to convert it into java. I know what encryption does, but the coding specifics between ASE/DSE/3DES, i need some help with. Basically, I'm trying to convert the $ldap_hash line into the the same equivalent java code. I can see it's using 3DES, but I've seen some very very different ways of implementing this. I has something going but I was running into an illegal key size. Couldn't figure that out so I'm retreating a bit and looking for help.
require_once('./path/to/nusoap.php');
 
 $soap_client = new soapclient('http://someurl.com/sugar/soap.php?wsdl');
 
 $user_name = 'matt';
 $user_password = 'mygoodsecret123';
 $app_name = 'myniceprogram';
 
 $key = 'abc123';  // LDAP Key as entered in Sugar
 $key = substr(md5($key),0,24);
 $iv = 'password';  // note that this is the word password, not the user's password or hash...
 $ldap_hash = bin2hex(mcrypt_cbc(MCRYPT_3DES, $key, $user_password, MCRYPT_ENCRYPT, $iv));
 $soap_client->call('login',array('user_auth'=>array('user_name'=>$user_name, 'password'=>$ldap_hash,'version'=>'.1'), 'application_name'=>$app_name));

Open in new window

0
Comment
Question by:kblackwel
3 Comments
 
LVL 19

Expert Comment

by:Michael701
Comment Utility
I might be totally wrong on this, but I seem to recall that the md5 function is specific to php and as I learned different in mysql. So, I'm thinking it might also be different in java. try echoing the key after the md5 in both java and php and see if they're the same

 $key = substr(md5($key),0,24);
echo $key;
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
Comment Utility
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
>>I has something going but I was running into an illegal key size. Couldn't figure that out so I'm retreating a bit and looking for help.

Yes, afaicr 3DES uses a 128-bit key, so it'll need to be padded
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Router for PHP reqeusts 12 29
how to resize preview image 4 28
Codiing Non-Existent Links 4 21
sql sentence 2 8
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

763 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

13 Experts available now in Live!

Get 1:1 Help Now