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

236
Views
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
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!