Transformar nodjs para php
ola boa semanas a todos, desde ja agradecer a ajuda de muitos por aqui nesse forum, gostaria de ver como transformo esse nodjs em php, já que sou muito leiga e não entendo basicamente nada de nodjs e muito pouco em php, não faço ideia de como se faz as contas e a programação em php, segue script abaixo <?php
// Geração de número aleatório com base nas seguintes entradas: serverSeed, clientSeed, nonce and cursor
function byteGenerator({ serverSeed, clientSeed, nonce, cursor }) { // Configurar variáveis do cursor let currentRound = Math.floor(cursor / 32). let currentRoundCursor = cursor. currentRoundCursor -= currentRound * 32. // Gere saídas até que o requisito do cursor seja preenchido while (true) { // Função HMAC usada para gerar entradas fornecidas em bytes const hmac = createHmac('sha256', serverSeed). hmac.update(`${clientSeed}:${nonce}:${currentRound}`). const buffer = hmac.digest(). // Atualizar cursor para a próxima iteração do loop while (currentRoundCursor < 32) { yield Number(buffer[currentRoundCursor]). currentRoundCursor += 1. } currentRoundCursor = 0. currentRound += 1. }
}// Converta a saída de hash do rng byteGenerator em flutuadores
function generateFloats ({ serverSeed, clientSeed, nonce, cursor, count }) { // Função gerador de números aleatórios const rng = byteGenerator({ serverSeed, clientSeed, nonce, cursor }). // Declarar bytes como matriz vazia const bytes = []. // Preencher matriz de bytes com conjuntos de 4 da saída RNG while (bytes.length < count * 4) { bytes.push(rng.next().value). }// Tradução de evento de jogo com casaEdge de 0,99 (1%)
const floatPoint = 1e8 / (float 1e8) houseEdge. // Ponto de falha arredondado para o denominador requerido
const crashPoint = Math.floor(floatPoint * 100) / 100. // Retornar bytes como flutuadores usando a função reduzir lodash return _.chunk(bytes, 4).map(bytesChunk => bytesChunk.reduce((result, value, i) => { const divider = 256 ** (i + 1). const partialResult = value / divider. return result + partialResult. }, 0) ). }. esse script no site phptester.net me retornaria o seguinte resultado semelhante a esse 2,57 desde já agredeço a atenção de todos obrigadaDiscussão (0)
Carregando comentários...