How to encrypt database SQLite using Adobe AIR 2.0

吃可爱长大的小学妹 提交于 2019-12-11 16:12:45

问题


i just wanna ask how to encrypt database using adobe air 2.0. I found some codes using Adobe air 1.5. here the codes:

// Include AIRAliases.js to use air.* shortcuts
var conn = new air.SQLConnection(); 
conn.addEventListener(air.SQLEvent.OPEN, openHandler); 
conn.addEventListener(air.SQLErrorEvent.ERROR, errorHandler); 
var dbFile = air.File.applicationStorageDirectory.resolvePath("DBSample.sqlite"); 

var encryptionKey = new air.ByteArray(); 
encryptionKey.writeUTFBytes("Some16ByteString"); // This technique is not secure! 

conn.openAsync(dbFile, air.SQLMode.CREATE, null, false, 1024, encryptionKey); 

function openHandler(event) 
{ 
    air.trace("the database opened successfully"); 
} 

function errorHandler(event) 
{ 
    if (event.error.errorID == 3138) 
    { 
        air.trace("Incorrect encryption key"); 
    } 
    else 
    { 
        air.trace("Error message:", event.error.message); 
        air.trace("Details:", event.error.details); 
    } 
}

it doesn't work. it just shows error : air.SQLMode is not an object

anybody can fix it? Thanks


回答1:


The reason you're seeing the air.* aliases is because the example is intended to be used in JavaScript. If you're using ActionScript you'll need to remove the air.* aliases and just import the classes instead.

For JavaScript, since there is no "import" statement, the AIR team created a file airaliases.js that creates aliases for all the AIR classes, so that you don't have to use the fully-qualified class name every time you want to use the class.



来源:https://stackoverflow.com/questions/4262953/how-to-encrypt-database-sqlite-using-adobe-air-2-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!