nativescript-secure-android-keystore
在 keystore 中加密和存储数据的 NativeScript 插件。
npm i --save nativescript-secure-android-keystore

npm npm Twitter Follow

在 Android keystore 中安全存储数据

Github

加密数据,并在需要使用时解密。使用 keystore 加密将数据保存在共享偏好设置中。目前仅适用于 Android。

先决条件 / 要求

Android 版本:最新版本

安装

tns plugin add nativescript-secure-android-keystore

使用

描述您插件的使用细节。如有需要,请提供 Android、iOS、Angular 的示例。参见 nativescript-secure-android-keystore

JavaScript

        
const SecureAndroidKeystore = require("nativescript-secure-android-keystore");

function createViewModel() {
...
var secure = new SecureAndroidKeystore.SecureAndroidKeystore();
secure.storeData('mykey', 'pass1234');
secure.retrieveData('mykey').then(res => {
console.log(res);
});
....
return viewModel;
}

TypeScript

     import { SecureAndroidKeystore } from 'nativescript-secure-android-keystore';


private secureAndroidKeystore: SecureAndroidKeystore;

//Inside some method
this.secureAndroidKeystore = new SecureAndroidKeystore();
this.secureAndroidKeystore.storeData('mykey','pass1234');
this.secureAndroidKeystore.retrieveData('mykey').then(res=>{
this.message = res;
console.log('message', this.message );
})

Angular TypeScript

app.module.ts
...
import { SecureAndroidKeystore } from 'nativescript-secure-android-keystore';
....

@NgModule({
.
.
.
bootstrap: [
AppComponent
],

providers: [
SecureAndroidKeystore
],
.
.
.
})

any.component.ts

...
import { SecureAndroidKeystore } from 'nativescript-secure-android-keystore';
....

constructor(private secureAndroidKeystore: SecureAndroidKeystore){

}

anyMethod(){
//Inside some method
this.secureAndroidKeystore.storeData('mykey','pass1234');
this.secureAndroidKeystore.retrieveData('mykey').then(res=>{
this.message = res;
console.log('message', this.message );
})

}

API

属性 默认值 描述
存储数据方法 storeData('key', 'passdata') 用于保存任何数据的方法
获取数据 retrieveData 用于获取数据的 方法,返回 promise 对象

许可证

Apache 许可证 2.0 版,2004 年 1 月

对于任何问题,请在 github 存储库中提出问题

教程

需要更多帮助才能开始?查看教程。