Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

encrypt & decrypt api data in localstorage

 async getCategory(){
         await this.$axios.$get("/api/v1/category2")
          .then(resp =>{
            const envryptedObject = AES.encrypt(JSON.stringify(resp),'MYKEY4DEMO');
            localStorage.setItem('envryptedObject', envryptedObject.toString());
			})
        },
        getmenuData(){
        const decrypted2 = AES.decrypt(localStorage.getItem('envryptedObject'), 'MYKEY4DEMO');
        const decryptedObject = decrypted2.toString(enc.Utf8);
        var dataq = JSON.parse(decryptedObject)
        this.menuEntrie = dataq;
        console.warn(this.menuEntrie);				
        },
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #encrypt #decrypt #api #data #localstorage
ADD COMMENT
Topic
Name
3+9 =