如何在ionic2 typescript文件中加密密码。我参考下面的链接并将pbkdf2模块导入到ionic2 app。 http://www.pydev.org/manual_adv_debugger.html
但是我收到了像 webpack_require 这样的错误.i(...)不是函数。任何人都可以帮我解决这个问题......
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { pbkdf2 } from '../../../node_modules/pbkdf2-sha256/lib/pbkdf2.js';
/*
Generated class for the Firstpage page.
See http://ionicframework.com/docs/v2/components/#navigation for more info on
Ionic pages and navigation.
*/
@Component({
selector: 'page-firstpage',
templateUrl: 'firstpage.html'
})
export class FirstpagePage {
key : any = "passwd";
salt :any ="salt";
res :any ;
constructor(public navCtrl: NavController, public navParams: NavParams) {}
ionViewDidLoad() {
console.log('ionViewDidLoad FirstpagePage');
}
encrypt(){
console.log("-----");
this.res = pbkdf2(this.key, this.salt, 1, 64);
console.log(this.res.toString('hex'))
}
}
答案 0 :(得分:1)
尝试在构造函数中定义pbkdf2
。
constructor(public navCtrl: NavController, public navParams: NavParams,
public crypt:pbkdf2) {}