Generating an ECP hash.

Jun 19, 2008 01:13

(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 talklib.pl, the hash is generated like so:

sub ecphash ( Read more... )

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

Leave a comment

soph June 19 2008, 08:47:48 UTC

ciaran@neo:~$ php

82da61aa724b5d149a9c5dc8682c2a45
ciaran@neo:~$
ciaran@neo:~$ perl
use Digest::MD5;
print Digest::MD5::md5_hex("md5test") . "\n";
82da61aa724b5d149a9c5dc8682c2a45
ciaran@neo:~$

Yes, they do the same. :D The "ecph" thing would be what's causing it - you're not prepending "ecph-" to the hash.

Reply

professormass June 19 2008, 15:04:57 UTC

Okay, so they do the same...has anybody tried this with the actual data it's supposed to be hashing? My concern is that the 'password' component isn't a clear-text password, but rather, something pre-encrypted and pulled from LJ's database.

Reply

soph June 19 2008, 15:33:48 UTC
Actually, the problem here isn't to do with the password, it's to do with the item IDs you're using.

The itemid you want is *not* the ID that's passed in the "itemid" field of the form (which is its ditemid), but instead the jitemid, which can be found as int($ditemid / 256). So for this comment I'm replying to, for example, the entry itemid is 786311, but its jitemid, which is what I need to hash, is int(786311 / 256) = 3071. Has together "307133966my plaintext password here" and you'll get the hash you want.

The parenttalkid is calculated in a similar way - the displayed comment ID here is 8695687, but the ID that you want to pass is int(8695687 / 256) = 33967. However, you're given this figure in the form already, so you don't have to calculate it yourself. [edit: Well, okay, maybe it's that -1 for the comment ID... but I know it's right for the entry ID.]

Reply

professormass June 19 2008, 16:47:55 UTC

SUCCESS!

Thank you!

Reply

soph June 19 2008, 17:23:39 UTC
No problem. I'm glad I could help. :D

(incidentally, if you're interested, the jitemid is sequential and can be used to find out how many posts have been made to the journal in question. For example, your post was the 3071th entry to lj_dev. The ditemid is defined as ($jitemid * 256) + $anum, where $anum is a random number between 0 and 255 generated at the time of posting, and jitemids are numbered starting at 1.)

Reply


Leave a comment

Up