May 2018


          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
 
FEEDS
 
ARCHIVES
 
RECENT ENTRIES
 
OTHER BLOGGERS
 
AGGREGATORS
 
SOCIAL NETWORKS
:: 12/09/2010 ::
Coding an AIR Encrypted SQLite Database
Return   Back To Top
AIR applications, as of AIR runtime 1.5 support encrypted SQLite databases. The SQLConnection class contains 'open' and 'openAsync' methods that include an optional encryptionKey parameter. The encryptionKey parameter is 16 bytes long and a ByteArray. Writing your AIR application's code to create and leverage this encryption key (using the SQLConnection class 'open' method) is shown below.

Explanation of the encryption process:

  • Create a seed string of your choice, mySeed.
  • Prepare a bytearray variable to hold the encryption key
  • Create the myKey ByteArray
    • Use hexToInt function and the seed, mySeed, to create the key
    • Use the writeByte method - Writes bytes to the byte stream
  • Create a File that will represent the SQLite database
  • Pass the key [a ByteArray], myKey, to the open method of the SQLConnection, dbConn


import flash.data.*;
import flash.filesystem.File;

private var dbConn:SQLConnection = new SQLConnection();
private var dbStatement:SQLStatement = new SQLStatement();

private function init(): void {
    // create a seed string of your choice
    var mySeed:String = "AdobeAIRIsAGreatProduct";

    // prepare a bytearray variable to hold the encryption key
     var myKey:ByteArray = new ByteArray();

    // create the myKey ByteArray
    var i:int = 0;
    for (var j:int=0; j<16; j++) {
        // use hexToInt function and the seed to create the key
        i = (hexToInt(mySeed.charCodeAt(j))*15) +
        hexToInt(mySeed.charCodeAt(j+1));

        // use the writeByte method - Writes byte to the byte stream
        myKey.writeByte(i&0x00FF);
    }
    // create a File that will represent the SQLite db
    var dbFile:File =
    File.desktopDirectory.resolvePath("Encryptedemployees.db");
    dbStatement.sqlConnection = dbConn;

    //pass the key, myKey, to the open method of the SQLConnection, dbConn
    dbConn.open(dbFile, SQLMode.CREATE, false, 2048, myKey);
}

private function hexToInt(hex:Number):int {
    return parseInt("0x" + hex);
}

This example is available here. The source code is available by right-clicking and selecting 'View Source' in this AIR application. You will need to install the Adobe AIR runtime if you do not already have it installed.

Some screenshots:

The SQLite database contains Lord of the Rings information.

A TitleWindow that displays the Lord of the Rings characters' images as read from the SQLite database.

Opening the database shows that the data is encrypted.

        Tip Jar:

 
 

canada goose femme pas cher Soldes Louboutin Chaussures Soldes Louboutin louis vuitton taschen outlet louboutin outlet uk billig canada goose canada goose tilbud goyard pas cher longchamp bags outlet Monlcer udsalg billige parajumpers YSL replica sac louis vuitton pas cher Canada Goose Pas Cher Canada Goose Outlet UK Moncler Outlet uk goyard replica bags polo Lacoste pas cher Bolsos Longchamp España Moncler Jakker tilbud Doudoune moncler pas cher Parajumpers Jakker tilbud Ralph Lauren Soldes Parajumpers Outlet louis vuitton replica Moncler Jas sale Billiga Canada Goose Jacka Canada Goose outlet Billiga Moncler Doudoune Canada Goose Pas Cher Canada Goose Pas Cher Louboutin Soldes Canada Goose Pas Cher Hemers replica Doudoune Canada Goose Pas Cher prada replica Canada Goose Pas Cher Canada Goose Soldes Doudoune Canada Goose Pas Cher Canada Goose Pas Cher Canada Goose outlet Canada Goose outlet Canada Goose outlet