Ed Charkow
Ed Charkow

Reputation: 61

Problems generating a signature with php

Having a little problem with an API that's out there and before I admit that it's broken and i'm not - figured someone might see what i'm doing wrong.

This is what they are asking for as part of the url - a signature that is formed by this: hex-encoded MD5(key + secret + timestamp)

And this is what i'm giving them that's failing:

$key = 'xxxxxxxxxxxxxxxxxx';
$secret = 'DeMxxxxxxxxxw';
$timestamped = $_SERVER['REQUEST_TIME'];
$signature = md5($key + $secret + $timestamped);

So am I doing something wrong or are they not playing with me well?

Upvotes: 0

Views: 107

Answers (4)

nachito
nachito

Reputation: 7035

Do you really want to add these together or to you want to concatenate them?

// Adding
$signature = md5($key + $secret + $timestamped);
// Concatenating
$signature = md5($key . $secret . $timestamped);

Upvotes: 1

Kae Verens
Kae Verens

Reputation: 4077

the concatenation operator in PHP is '.', not '+'

Upvotes: 1

Simone
Simone

Reputation: 21272

Maybe you want to use . (concatenation) instead of + (sum)

$signature = md5($key . $secret . $timestamped);

Upvotes: 3

Wiseguy
Wiseguy

Reputation: 20873

I think you mean to concatenate the strings with . instead of add numerically with +.

$signature = md5($key . $secret . $timestamped);

Upvotes: 2

Related Questions