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

244
Vistas
Convert function to javascript, calling from c++ to node.js server - encryption

I'm trying to encrypt a string using the juce framework generatekeypair, this create a RSA keypair and splits it into 2 parts, (and puts it in hex format I think).

This is the working code I'm using in c++:

const juce::String encryptString (const juce::String& str)
{
    juce::RSAKey private_key2 ("thisistheprivatekeypart1,thisistheprivatekeypart2");
    auto utf8 = str.toUTF8();
       auto* utf8Address = utf8.getAddress();
       juce::MemoryBlock plainMemoryBlock(utf8Address, utf8.sizeInBytes());

       juce::BigInteger sourceInteger;
       sourceInteger.loadFromMemoryBlock(plainMemoryBlock);

       if (!sourceInteger.isZero())
       {
           juce::BigInteger encodedInteger(sourceInteger);
           private_key2.applyToValue(encodedInteger);

           juce::MemoryBlock encodedMemoryBlock = encodedInteger.toMemoryBlock();

           return encodedMemoryBlock.toBase64Encoding();
       }

       return {};
}

Now i'm doing my first steps in node.js, i've successfully setup a server that takes and sends parameters, does anyone know how to write this function in node.js?

On the juce website they have this unconfirmed java snippet but it's not helping me a lot:

public class RSAKey
{
    static BigInteger applyToValue (BigInteger value, String key_part1, String key_part2)
    {
        BigInteger result = BigInteger.ZERO;
        BigInteger part1 = new BigInteger (key_part1, 16);
        BigInteger part2 = new BigInteger (key_part2, 16);
 
        if (part1.equals (BigInteger.ZERO) || part2.equals (BigInteger.ZERO)
             || value.compareTo (BigInteger.ZERO) <= 0)
            return result;
 
        while (! value.equals (BigInteger.ZERO))
        {
            result = result.multiply (part2);
            BigInteger[] div = value.divideAndRemainder (part2);
            value = div[0];
            result = result.add (div[1].modPow (part1, part2));
        }
 
        return result;
    }
}
about 4 years ago · Juan Pablo Isaza
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