Skip to main content
Participant
November 3, 2011
Question

EncryptedLocalStorage not working

  • November 3, 2011
  • 2 replies
  • 685 views

I have been using the following but it throws an error "Result of expression air.EncryptedLocalStorage[undefined]is not an object". Whats happening?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

<script type="text/javascript" src="js/jquery.js"></script>

<script type="text/javascript" src="AIRAliases.js"></script>

<script type="text/javascript">

$(document).ready(function(){

$("#but").click(function(){

  var str = "Bob"; 

  var data = new air.ByteArray();

  data.writeUTFBytes(str);

try {

  air.EncryptedLocalStore.setItem('firstName', data);

} catch(e) {

alert(e)

}

})   

})

</script>

</head>

<body>

<input id="but" type="button" value="button" />

</body>

</html>

This topic has been closed for replies.

2 replies

November 7, 2011

Great! Thanks for your reporting and sharing your solution!

s_lantonAuthor
Participant
November 3, 2011

OK..answering my own question, I got this working..if anyone is interested

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

<script type="text/javascript" src="js/jquery.js"></script>

<script type="text/javascript" src="AIRAliases.js"></script>

<script type="text/javascript">

$(document).ready(function(){

       

        $('#logon').click(function(){

        var data = null;

        var url = null;

       url=$('#urlname').val()      

    

        data = new air.ByteArray();

       

        data.writeUTFBytes(url);

       

        try{

        air.EncryptedLocalStore.setItem( 'url', data );

        }catch(e){

            alert(e)

        }

        })

       

        $('#recall').click(function(){

       

        var recalledData = air.EncryptedLocalStore.getItem('url');

        $('#rememberUrl').val(recalledData.readUTFBytes( recalledData.bytesAvailable ));

       

        })

       

});

</script>

</head>

<body>

<p>

  <input type="button" id="logon" value="sign" />

  <input type="text" name="textfield" id="urlname" />

</p>

<p>

  <input  type="button" id="recall" value="recall" />

  <input type="text" name="textfield2" id="rememberUrl" />

</p>

</body>

</html>