我想在我的自定义存储Cordova插件中使用AES加密

时间:2019-11-30 16:08:18

标签: cordova cordova-plugins visual-studio-cordova

我的应用程序中有AES加密cordova插件,还有自定义的本地存储插件。如何在现有存储插件中使用AES加密插件。

1 个答案:

答案 0 :(得分:1)

首先安装https://github.com/Ideas2IT/cordova-aes256

那些

ionic cordova plugin add cordova-plugin-aes256-encryption

cordova plugin add cordova-plugin-add-swift-support --save

然后加密您的数据

declare var mycordova: any;


   mySecureKey: String = '12345678910123456789012345678901'; // Any string, the length should be 32
   mySecureIV: String = '1234567891123456'; // Any string, the length should be 16

然后按顺序浏览文档

 let data = "test";
 encrypt(this.mySecureKey, this.mySecureIV, data); 

然后将其存储

var storage = window.localStorage;
var value = storage.getItem(key); // Pass a key name to get its value.
storage.setItem(key, your_data) // Pass a key name and its value to add or update