0

I have a below cSharp code that does encryption with a public key. I was asked to do the same with Javascript/NodeJS. Is this even possible to do it? This is the first time I doing any kind of encryption. Please help me understanding what are the difficulties I may face if I proceed for this. Are there any plugins to do this?

public static string EncryptAsymmetric(string encryptText, string publicKey)
    {
        byte[] buffer;
        bool fOAEP = false;
        byte[] bytes = Encoding.UTF8.GetBytes(encryptText);
        using (RSACryptoServiceProvider provider = new RSACryptoServiceProvider())
        {
            provider.FromXmlString(publicKey);
            buffer = provider.Encrypt(bytes, fOAEP);
        }
        return Convert.ToBase64String(buffer);
    }

Thanks in advance

Cleptus
  • 3,446
  • 4
  • 28
  • 34
  • Possible duplicate of [RSA Encryption Javascript](https://stackoverflow.com/questions/17685645/rsa-encryption-javascript) – Cleptus Jan 31 '19 at 15:30
  • If you are looking a RSA implementation in javascript, this questio is not related to c#. – Cleptus Jan 31 '19 at 15:31

0 Answers0