Skip to content
Jordan Duerksen edited this page Jun 11, 2018 · 1 revision

Tungsten.Encryption.RSA encapsulates the functionality of the static RSAMethods methods to provide the programmer with a simplified class interface.

var message = "This is a test string";
using(var rsa = new W.Encryption.RSA(2048))
{
    var cipher = rsa.Encrypt(message);
    //do something with the data
    var decrypted = rsa.Decrypt(cipher);
}

Note that the public and private keys are generated in the constructor. The larger the key, the more time and CPU time is required to generate the keys. This can block the calling thread for some time. Therefore, one should wrap the creation of the RSA instance in a Task or background thread. Asynchronous key creation may be added in the future.

Clone this wiki locally