[Resolvido] transformar Js em php
Pessoal tenho um script em js gostaria de rodar ele somente no php e não tenho noção de php, como eu faria isso segue o codigo abaixo
//the seed pair itself
var clientSeed = "5e3c6ad2-2874-4693-81ea-73d241b3c06b";
var serverSeed = "2304528a-c364-4b48-94d4-0f232bd65a2d";
var nonce = 130; //bet made with seed pair//crypto lib for hmac function
var crypto = require('crypto');
var roll = function(key, text) {
var hash = crypto.createHmac('sha512', key).update(text).digest('hex');
var index = 0;
var lucky = parseInt(hash.substring(index * 5, index * 5 + 5), 16);
//keep grabbing characters from the hash while greater than
while (lucky >= Math.pow(10, 6)) {
index++;
lucky = parseInt(hash.substring(index * 5, index * 5 + 5), 16);
//if we reach the end of the hash, just default to highest number
if (index * 5 + 5 > 128) {
lucky = 99.99;
break;
}
}
lucky %= Math.pow(10, 4);
lucky /= Math.pow(10, 2);
return lucky;
}
console.log(roll(serverSeed, clientSeed+'-'+nonce));
Desde já agradeço a atenção de todosDiscussão (5)
Carregando comentários...