Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

182
Views
PHP: cree una firma usando Nonce y marca de tiempo (se proporciona el equivalente de JS y Python)

Estoy tratando de conectarme a una API y solo proporcionan guías para python y Javascript. Estoy tratando de encontrar el equivalente para php pero me quedo corto.

Para referencia adicional: https://docs.deribit.com/#authentication

No puedo obtener la firma adecuada en PHP.

JavaScript:

 var timestamp = Date.now(); var nonce = "abcd"; var data = ""; var signature = CryptoJS.HmacSHA256(`${timestamp}\n${nonce}\n${data}`, accessSecret).toString();

Pitón:

 timestamp = round(datetime.now().timestamp() * 1000) nonce = "abcd" data = "" signature = hmac.new( bytes(clientSecret, "latin-1"), msg=bytes('{}\n{}\n{}'.format(timestamp, nonce, data), "latin-1"), digestmod=hashlib.sha256 ).hexdigest().lower()

PHP: (*No sé cómo crear el nonce)

 $timestamp = number_format(microtime(true) * 1000, 0, '.', ''); $nonce = number_format(microtime(true) * 1000, 0, '.', ''); $data = ""; $key = $timestamp.$nonce.$data; $sign = hash_hmac('sha256',$key,$secret); $sign = bin2hex($sign);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Para la generación aleatoria requerida 'a-z0-9', 8 caracteres, puede usar chr y rand para hacer el trabajo.

Por lo tanto, intente lo siguiente

 <?php $x1= chr(rand(0,25)+97) ; $x2= chr(rand(0,9)+48) ; $x3= chr(rand(0,25)+97) ; $x4= chr(rand(0,9)+48) ; $x5= chr(rand(0,25)+97) ; $x6= chr(rand(0,9)+48) ; $x7= chr(rand(0,25)+97) ; $x8= chr(rand(0,9)+48) ; $nonce = $x1.$x2.$x3.$x4.$x5.$x6.$x7.$x8; ?>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!