Well, the code isn’t indented, so I guess it’s:
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);
}
The 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 obtain the information processed), but this is not present in the code indicated.