Another possible avenue is to use AES Encryption (msdn link:
AES Class)
Since AES is symmetric-key encryption, all you need is a passphrase that you can remember and you can encrypt just about anything. You can use a SHA512 hash to generate your crypto keys.
This example includes an extension function byte[].GetSubArray(int, int).
public byte[] Encrypt(string passphrase, string text)
{
byte[] hashedPassphrase;
using (HashAlgorithm hash = SHA512.Create())
{
hashedPassphrase = hash.ComputeHash(Encoding.UTF8.GetBytes(passphrase));
}
using (Aes crypto = Aes.Create())
{
crypto.IV = hashedPassphrase.GetSubArray(0, 16);
crypto.Key = hashedPassphrase.GetSubArray(16, 32);
using (ICryptoTransform encryptor = crypto.CreateEncryptor(crypto.Key, crypto.IV))
{
MemoryStream memStream = new MemoryStream();
using (CryptoStream encStream = new CryptoStream(memStream, encryptor, CryptoStreamMode.Write))
{
encStream.Write(Encoding.UTF8.GetBytes(text), 0, text.Length);
encStream.FlushFinalBlock();
return memStream.ToArray();
}
}
}
}
Decryption is nearly the same code except crypto.CreateEncryptor() becomes crypto.CreateDecryptor
and
the actual decryption code is a little different.
string plainText;
MemoryStream memStream = new MemoryStream(encryptedPassword);
CryptoStream decStream = new CryptoStream(memStream, decryptor, CryptoStreamMode.Read);
using (StreamReader reader = new StreamReader(decStream))
{
plainText = reader.ReadToEnd();
}