Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

316
Visualizações
get negative D, when I try to generate private key RSA

I have the method to calculate D(private key) for RSA. The method uses extended Euclidean algorithm. So sometimes I get negative D and it isn't right how I can fix it? D * e mod (p-1)(q-1)=1; here is the code of the method

public static BigInteger extEuclid(BigInteger a, BigInteger b)
{

        BigInteger x = BigInteger.ZERO, y = BigInteger.ONE, lastx = BigInteger.ONE, lasty = BigInteger.ZERO, temp;
        while (!b.equals(BigInteger.ZERO))
        {
            BigInteger q = a.divide(b);
            BigInteger r = a.mod(b) ;
        a = b;
        b = r;

        temp = x;
        x = lastx.subtract(q.multiply(x));
        lastx = temp;

        temp = y;
        y = lasty.subtract(q.multiply(y));
        lasty = temp;
    }

    return lastx;
}


public void calcD(){
  d = extEuclid(e, fEuler);
}
over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda