Skip to content

Public Private Encryption

Jay Tuley edited this page Nov 18, 2013 · 1 revision

For Public Key Cryptography, Keyczar uses RSA.

But for more general safer usage, see Session Encryption

Use the KeyczarTool to create an asymmetric crypt key set

:> KeyczarTool.exe create --location=path_to_private_key_set --purpose=crypt --asymmetric

Then generate a primary private key

:> KeyczarTool.exe addkey --location=path_to_private_key_set --status=primary

Then export a public keyset

:> KeyczarTool.exe pubkey --location=path_to_private_key_set --destination=path_to_public_key_set

In your project to encrypt,

using(var encrypter = new Encrypter("path_to_public_key_set"))
{
     return encrypter.Encrypt(plaintext);
}

Then to decrypt,

using(var crypter = new Crypter("path_to_private_key_set"))
{
     return crypter.Decrypt(ciphertext);
}