Loading ...
Sorry, an error occurred while loading the content.

213Re: [id-js] localStorage + JSON + Blowfish

Expand Messages
  • herdian ferdianto
    Jun 19, 2010
    • 0 Attachment
      Pak,

      Blowfish itu block cipher, dengan ukuran 64 bit per enkripsi = 8 byte. Jadi hasil dekripsi akan selalu kelipatan 8
      itu 000 dibelakang adalah paddingnya, Kalau mau yg stream cipher bisa pakai rc4


      2010/6/20 Fadjar Nurswanto <mailinglist@...>
      script blowfish.js menggunakan http://dren.ch/js_blowfish/
      monambahkan method dan object blowfish pada Storage dengan script
      sebagai berikut:

      if(window.localStorage){
             Storage.prototype.bf=new Blowfish(location.href);
             Storage.prototype.save=function(k,v){
                     this.setItem(k, this.bf.encrypt(JSON.stringify(v)));
             };
             Storage.prototype.load=function(k){
                     return JSON.parse(this.bf.decrypt(this.getItem(k)));
             };
      }else{alert("Your browser does not support localStorage");};

      dan dicoba dengan script sebagai berikut:

      var oSrc={
             arrai:['test1','test2','test3','test4','test5','test6'],
             o:{
                     param1:'testParam1',
                     param2:'testParam2'
             }
      }
      localStorage.save('myDB',oSrc);

      JSON stringify menghasilkan:
      {"arrai":["test1","test2","test3","test4","test5","test6"],"o":{"param1":"testParam1","param2":"testParam2"}}

      yang selanjutnya di encrypt dengan blowfish dan tersimpan di dalam
      localStorage dengan key myDB.

      Permasalahan timbul ketika diloading:

      var oTrgt=localStorage.load('myDB');

      ternyata hasil decrypt blowfish menghasilkan
      {"arrai":["test1","test2","test3","test4","test5","test6"],"o":{"param1":"testParam1","param2":"testParam2"}}000

      Pertanyaan:
      1. script blowfish nya kurang pas ?
      2. atau JSON bermasalah dengan encrypt/decrypt ?
      3. apa script saya ada yang kurang ?
      4. ada solusi ?

      Terima kasih,
      --
      Fadjar Nurswanto
      http://blog.rindudendam.net
      http://rindudendam.deviantart.com

      Sent from BDG Powered by RinduDendam PearlBerry®


      ------------------------------------

      Yahoo! Groups Links

      <*> To visit your group on the web, go to:
         http://groups.yahoo.com/group/id-js/

      <*> Your email settings:
         Individual Email | Traditional

      <*> To change settings online go to:
         http://groups.yahoo.com/group/id-js/join
         (Yahoo! ID required)

      <*> To change settings via email:
         id-js-digest@yahoogroups.com
         id-js-fullfeatured@yahoogroups.com

      <*> To unsubscribe from this group, send an email to:
         id-js-unsubscribe@yahoogroups.com

      <*> Your use of Yahoo! Groups is subject to:
         http://docs.yahoo.com/info/terms/




      --
      http://m.ferdianto.com/
    • Show all 9 messages in this topic