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

312
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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