This quick-start provides just enough information to get you started using the IQryptParse iOS framework within XCode using Swift programming language.

Downloading the framework

First you will need to download IQrypt framework from here.

Add the reference and import the framework

After you have downloaded the IQryptParse.framework, locate it in Finder and drag and drop it into your XCode project. IQryptParse.framework is depended on Parse.framework which can be taken from parse.com website.

Add Required import statements

As a minimum you will need the following import statements:

import IQryptParse;

import Parse;

Encryption settings

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

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

To let IQrypt encrypt a PFObject field, you will have to use IQryptParseConfigurator.encryptField(...) method. Example:


 IQryptParseConfigurator.encryptField("Armor2", fieldKey: "myIntField", encryptionType: EncryptionType.OPE,fieldTemplate: NSNumber(int: 0));

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

 IQryptParseConfigurator.setEncryptionChiper(.AES256, encryptionKey: "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:

var vKey = Vault.getKey(keyName:"key1", username:"UsernameParse");
var realEncryptionKey = Vault.decrypt(key:vKey, password:EPassword);//we suppose EPassword is taken from UI filled by the user of app
IQryptConfigurator.setEncryptionChiper(.AES256, encryptionKey:realEncryptionKey );

And then initialize Parse:

   Parse.setApplicationId("app_ID", clientKey: "client_Key");


Create and store an IQryptPFObject

IQryptPFObject is derived from IQryptPFObject and transparently encrypts fields without any extra intervention.

Here is how your would store a ParseObject using Parse iOS SDK:

var obj = PFObject(className:"Armor");
obj.setValue(30,forKey: "myIntField");

obj.save();

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

var obj = IQryptPFObject(className:"Armor");
obj.setValue(30,forKey: "myIntField");

obj.save();

Find an Existing IQryptPFObject

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

Here is an example how you would do with Parse iOS SDK

   var query = PFQuery(className: "Armor");
   var objFromServer = query.getObjectWithId(obj.objectId);
   var myIntValue = objFromServer.valueForKey("myIntField") ;

And here is an example by using IQryptParse SDK

   var query = IQryptPFQuery(className: "Armor");
   var objFromServer = query.getObjectWithId(obj.objectId);
   var myIntValue = objFromServer.valueForKey("myIntField") ;

Update an Existing IQryptPFObject

To update an existing PFObject using Parse iOS SDK you would do:


var query = IQryptPFQuery(className: "Armor");
var objFromServer = query.getObjectWithId(obj.objectId);
objFromServer.setValue(40,forKey:"myIntField");
objFromServer.save();

To update an existing IQryptPFObject you will have to do:


var query = IQryptPFQuery(className: "Armor");
var objFromServer = query.getObjectWithId(obj.objectId);
objFromServer.setValue(40,forKey:"myIntField");
objFromServer.save();

Delete an Existing IQryptPFObject

To delete an existing PFObject using Parse iOS SDK you would do:


var query = PFQuery(className: "Armor");
var objFromServer = query.getObjectWithId(obj.objectId);
objFromServer.delete();

To delete an existing IQryptPFObject you will have to do:


var query = IQryptPFQuery(className: "Armor");
var objFromServer = query.getObjectWithId(obj.objectId);
objFromServer.delete();