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

315
Vistas
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 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