Professor Mass (professormass) wrote in lj_dev,
Professor Mass

  • Mood:

Generating an ECP hash.

(Bumping this up from earlier comments in the hopes of assistance.)

I'm stuck on one issue. I've used the form sent out via comment emails as a basis, but I'm having a hard time generating the ECP hash.

In, the hash is generated like so:

sub ecphash {
my ($itemid, $talkid, $password) = @_;
return "ecph-" . Digest::MD5::md5_hex($itemid . $talkid . $password);

In PHP, I'm doing this:

$TalkID = '1010';
$ItemID = '010101';
$Password = 'mypassword';
$ECPHash = md5($ItemID . $TalkID . $Password);

However, the submitted form is rejecting the hash as having the wrong password. Is there some further munging of the password that needs to be done to generate a valid password for hashing? Or is the PHP md5() doing something different than the Perl library?

Now, I know the TalkID and the ItemID aren't the problem, which leaves me with one of two options:

1) The MD5 hashing functions work differently between PHP and Perl (which would be odd).

2) The password being used to generate the hash on LJ's side is not a clear-text password, but rather some sort of encrypted form of the password being pulled from their database

Any clues?

Edited To Add: Thank you, soph! Here is the fixed and working code:

	$Journal = 'JournalReceivingReply';
	$Poster = 'UsernameOfReplyingParty';
	$TalkID = '01010';
	$DItemID = '101010';
	$JItemID = intval($DItemID/256);
	$Password = 'apassword';
	$ECPHash = md5($JItemID . $TalkID . $Password);

	echo '
		<form method="post" target="ljreply" action="">
			<input type="hidden" name="usertype" value="user" />
			<input type="hidden" name="parenttalkid" value="' . $TalkID . '" />
			<input type="hidden" name="itemid" value="' . $ItemID . '" />
			<input type="hidden" name="journal" value="' . $Journal . '" />
			<input type="hidden" name="userpost" value="' . $Poster . '" />
			<input type="hidden" name="ecphash" value="ecph-' . $ECPHash . '" />
			<input type="hidden" name="encoding" value="windows-1252" />
			<b>Subject:</b> <input name="subject" size="40" value="" />
			<br />
			<textarea rows="10" cols="50" wrap="soft" name="body"></textarea>
			<br />
			<input type="submit" value="Post Reply" />

Tags: *revisit, client, client: posting, code: perl, code: php

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded