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

313
Views
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 answers
Answer question

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 Report
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!