This quick-start provides just enough information to get you started using IQryptParse in C# within VisualStudio.

Downloading the C# libraries and add references

You will have to download .NET assemblies from here. IQryptParse is dependent on following libraries:

  • net version is dependent on Newtonsoft.Json.dll, Parse.dll and Parse.NetFx45.dll.
  • unity version is dependent on Parse.Unity.dll
  • universal version is dependent on Newtonsoft.Json.dll, Parse.dll and Parse.WinRT.dll.

You can find those assemblies inside downloaded package. In VisualStudio add all assemblies as references (for required platform).

Add Required using Statements

As a minimum you will need the following using statements:

using IQryptParse;
using IQrypt;
using Parse;

Encryption settings

With IQryptParse you can encrypt fields of a ParseObject with different encryption schemes: OPE, DET, RND.

  • OPE - order preserving encryption
  • DET - deterministic encryption
  • RND - randomized encryption

To let IQrypt to encrypt a ParseObject field you will have to use IQryptParseConfigurator.EncryptField(...) method. Example:

 IQryptParseConfigurator.EncryptField("Armor", "myIntField", EncryptionType.OPE, typeof(int));

After you set how fields should be encrypted, you will have to set the cipher and the encryption key:

 IQryptParseConfigurator.SetEncryptionChiper(Cipher.AES256, "my_super_secret");

*On production apps get the encryption key from a safe location- see Vault (do not embed it into the code).

Example using the key from Vault:

ParseUser user = await ParseUser.LogInAsync("yourUserName", "your_ParsePwd");
VaultKey vKey = Vault.GetKey("key1",user.Username);
string realEncryptionKey = Vault.Decrypt(vKey, EPassword);//we suppose EPassword is taken from UI filled by the user of app
IQryptParseConfigurator.SetEncryptionChiper(Cipher.AES256, realEncryptionKey );

And then initialize Parse:

 ParseClient.Initialize("Application_ID", ".NET_Key");


Create and store an IQryptParseObject

IQryptParseObject is derived from ParseObject and transparently encrypt fields without any extra intervention. Here is how your would store a ParseObject using Parse .NET SDK:

ParseObject obj = new ParseObject("Armor");
obj["myIntField"]=30;

await obj.SaveAsync();

And here is an example of creating and store an IQryptParseObject using IQryptParse SDK

IQryptParseObject obj = new IQryptParseObject("Armor");
obj["myIntField"]=30;

await obj.SaveAsync();

Find an Existing IQryptParseObject

In this example we will read back an IQryptParseObject assuming we know the Id value.

Here is an example how you would do with Parse .NET SDK

   ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Armor");
   ParseObject objFromServer = await query.GetAsync(obj.ObjectId);
   int myIntValue = (int)objFromServer["myIntField"];

And here is an example by using IQryptParse SDK

   ParseQuery<IQryptParseObject> query = new ParseQuery<IQryptParseObject >("Armor");
   IQryptParseObject objFromServer = await query.GetAsync(obj.ObjectId);
   int myIntValue = (int)objFromServer["myIntField"];

Update an Existing IQryptParseObject

To update an existing ParseObject using Parse .NET SDK you would do:

ParseQuery<ParseObject> query = new ParseQuery<ParseObject >("Armor");
ParseObject objFromServer = await query.GetAsync(obj.ObjectId);
objFromServer["myIntField"]=40;
await objFromServer.SaveAsync();

To update an existing IQryptParseObject you will have to do:


ParseQuery<IQryptParseObject> query = new ParseQuery<IQryptParseObject >("Armor");
IQryptParseObject objFromServer = await query.GetAsync(obj.ObjectId);
objFromServer["myIntField"]=40;
await objFromServer.SaveAsync();

Delete an Existing IQryptParseObject

To delete an existing ParseObject using Parse .NET SDK you would do:


ParseQuery<ParseObject> query = new ParseQuery<ParseObject >("Armor");
ParseObject objFromServer = await query.GetAsync(obj.ObjectId);
await objFromServer.DeleteAsync();

To delete an existing IQryptParseObject you will have to do:


ParseQuery<IQryptParseObject> query = new ParseQuery<IQryptParseObject >("Armor");
IQryptParseObject objFromServer = await query.GetAsync(obj.ObjectId);
await objFromServer.DeleteAsync();

Full Sample Program

using System;
using System.Threading.Tasks;
using IQryptParse;
using Parse;
using IQrypt;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Task.Run(async () =>
                {
                    IQryptParseConfigurator.EncryptField("Armor", "myIntField", EncryptionType.OPE, typeof(int));
                    IQryptParseConfigurator.SetEncryptionChiper(Cipher.AES256, "my_super_secret");
                    ParseClient.Initialize("Application_ID", ".NET_Key");


                    IQryptParseObject obj = new IQryptParseObject("Armor");
                    obj["myIntField"] = 30; //field is encrypted
                    //insert
                    await obj.SaveAsync();

                    ParseQuery<IQryptParseObject> query = new ParseQuery<IQryptParseObject>("Armor");
                    //read the object from Parse service
                    IQryptParseObject objFromServer = await query.GetAsync(obj.ObjectId);
                    int myIntValue = (int)objFromServer["myIntField"];//field is decrypted
                    //update
                    objFromServer["myIntField"] =  40;
                    await objFromServer.SaveAsync();

                    //delete
                    await objFromServer.DeleteAsync();
                }).Wait();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

        }
    }
}