📜  加密和解密本地存储中的 api 数据 - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:33.306000             🧑  作者: Mango

代码示例1
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);                
        },