Well, the code is not indented, so I suppose it is:
def createSignature(clientId, apiKey, privateKey, nonce):
message = str(nonce) + str(clientId) + apiKey
signature = hmac.new(privateKey, message, digestmod=hashlib.sha256).hexdigest()
That would be exactly:
function createSignature($id, $pk, $sk, $nonce){
$message = $nonce . $id . $pk;
$signature = hash_hmac('sha256', $message, $sk, false);
}
hash_hmac
already has the result in hexadecimal, there is no reason to convert it , so there is no equivalent of .hexdigest()
being used. Of course you should add some return
(or some other method to get the information processed), but that is not present in the given code.