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

310
Vistas
How to sign data with RSA private Key on Javascript/jquery

I got this C# code but I need it to be done in Javascript. The idea is that I need to execute this bit of code when there is no internet in the browser, basically, I have to save some data in the local storage and then use them to execute this method to generate a private key.

private static string SignData(string ppath,string ppass)
{
    X509Certificate2 keyStore = new X509Certificate2(ppath, ppass);
    RSA privateKey = keyStore.GetRSAPrivateKey();
    byte[] iicSignature = privateKey.SignData(Encoding.ASCII.GetBytes(pConcat), HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);

    byte[] iic = ((HashAlgorithm)CryptoConfig.CreateFromName("MD5")).ComputeHash(iicSignature);
    return BitConverter.ToString(iic).Replace("-", string.Empty);
}

P.S: I managed to extract the private key and save it to local storage.Now I need to sign some data with this key,SHA256 algorithm and pkcs1 padding.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

First of use Bouncy Castle to extract your private key from the certificate and convert it to pkcs8.

Then you will need to find a javascript library that does sign data with a private key. I suggest you use the window.crypto library that is supported by most browsers. It has a method called window.crypto.subtle.sign() which signs data using a private key you have to import with window.crypto.subtle.importKey() you can read more here about this library.

And finally you will need a md5 library to hash the signed data. You can find that here.

It's mostly what you've talked about in this chat.

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