Password encryption in C#

In C# you can use the class RSACryptoServiceProvider using the following public key ;


After the encryption, the byte array (byte[]) must be converted to base64.


Here you find a full console program example in C# (please replace the password to encrypt yours) :



using System;

using System.Security.Cryptography;

using System.Text;


namespace WinBIZCloudAPIEncrypt


  public class Program


    #region Public Methods

    public static string Encrypt(string publicKey, string data)


      var cspParams = new CspParameters {ProviderType = 1};

      var rsaProvider = new RSACryptoServiceProvider(cspParams);


      var plainBytes = Encoding.UTF8.GetBytes(data);

      var encryptedBytes = rsaProvider.Encrypt(plainBytes, false);

      var encryptedString = Convert.ToBase64String(encryptedBytes);

      return encryptedString;


    public static void Main(string[] args)


      var publicKey =


      var passwordToEncrypt = "Password1!";

      var passwordEncrypted = Encrypt(publicKey, passwordToEncrypt);









Was this article helpful?
0 out of 1 found this helpful
Have more questions? Submit a request