Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

228
Vistas
Cómo convertir correctamente la cadena de clave a bs58 a unit8 en jQuery

Estoy trabajando con Solana Blockchain en JavaScript.

Tengo la siguiente dirección de cadena clave que quiero decodificar o convertir a BASE58 a UINT8 Decoder . ¿Cómo puedo lograr eso en JavaScript o incluso a través de jQuery?

 <script> var address = "9vpsmXhZYMpvhCKiVoX5U8b1iKpfwJaFpPEEXF7hRm9N"; //var bs58_decode(address); /* My result should look something like below { 132,167, 105, 60, 17, 211, 120, 243, 197, 99, 113, 34, 76, 127, 190, 18, 91, 246, 121, 93, 189, 55, 165, 129, 196, 104, 25, 157, 209, 168, 165, 149, ] */ </script>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Todos los créditos son para el autor de esta biblioteca simple que puede encontrar aquí https://gist.github.com/diafygi/90a3e80ca1c2793220e5/

 var from_b58 = function( S, //Base58 encoded string input A //Base58 characters (ie "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz") ) { var d = [], //the array for storing the stream of decoded bytes b = [], //the result byte array that will be returned i, //the iterator variable for the base58 string j, //the iterator variable for the byte array (d) c, //the carry amount variable that is used to overflow from the current byte to the next byte n; //a temporary placeholder variable for the current byte for(i in S) { //loop through each base58 character in the input string j = 0, //reset the byte iterator c = A.indexOf( S[i] ); //set the initial carry amount equal to the current base58 digit if(c < 0) //see if the base58 digit lookup is invalid (-1) return undefined; //if invalid base58 digit, bail out and return undefined c || b.length ^ i ? i : b.push(0); //prepend the result array with a zero if the base58 digit is zero and non-zero characters haven't been seen yet (to ensure correct decode length) while(j in d || c) { //start looping through the bytes until there are no more bytes and no carry amount n = d[j]; //set the placeholder for the current byte n = n ? n * 58 + c : c; //shift the current byte 58 units and add the carry amount (or just add the carry amount if this is a new byte) c = n >> 8; //find the new carry amount (1-byte shift of current byte value) d[j] = n % 256; //reset the current byte to the remainder (the carry amount will pass on the overflow) j++ //iterate to the next byte } } while(j--) //since the byte array is backwards, loop through it in reverse order b.push( d[j] ); //append each byte to the result return new Uint8Array(b) //return the final byte array in Uint8Array format } // example var mapping = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; console.log(from_b58("9vpsmXhZYMpvhCKiVoX5U8b1iKpfwJaFpPEEXF7hRm9N", mapping));

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda