Защищённая БД SQLite для AIR-приложений
Опубликовал Андрей "авиатор" Алексеев — Понедельник, 28 сентября, 2009 — 11:46import 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 = "AIR15IsAGreatProduct"; // 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); } 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); }
Вот так выглядит создание защищённой SQLite-БД для использования в AIR. Увидел в Flex Cookbook, рецепт написал Майкл Гивенс.
В категории (ях) AIR | 2 комментария (ев)
2 комментария (ев) »
RSS для комментариев. TrackBack URI
Скажите и вы что-нибудь
© 2008, Adobe — наш верный друг. Все права защищены.
Работает под управлением WordPress и темы GimpStyle, созданной Horacio Bella.
RSS-фид сообщений | RSS-фид комментариев | Валидный XHTML- и CSS-код.

Привіт.
На Adobe help є приклад генерування ключа за допомогою EncryptionKeyGenerator.
Можливо, стане в пригоді
Комментарий от Christie — октября 5, 2009 #
Спасибо, думаю знадобиться!
Комментарий от Андрей "авиатор" Алексеев — октября 6, 2009 #