Struggling to hash passwords for login on my Ionic 3 app, I attempted using jsencrypt following a tutorial but encountered issues as I couldn't grasp how it works...
Here's what I tried :
npm install --save jsencrypt
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { ApiDatabaseService } from '../../providers/api-database-service';
import Encrypt from 'jsencrypt';
import { Injectable } from '@angular/core';
@Component({
selector: 'page-Login',
templateUrl: 'Login.html'
})
@Injectable()
export class LoginPage {
private prem: string = `my_key`;
Users:any = []; // Contains all users
constructor(public navCtrl: NavController, public serviceOne: ApiDatabaseService) {
this.serviceOne.getDataUser().subscribe( // Calling API to access database
data => this.Users = data
);
}
public create(name: string): string { // Password encryption function
let encrypt = new Encrypt.JSEncrypt();
encrypt.setPublicKey(this.pem);
return encrypt.encrypt(name);
};
}
Encountering this error :
Typescript Error
Property 'pem' does not exist on type 'LoginPage'.
Additionally, while Ionic 2 has extensive documentation like , there seems to be a lack of resources for Ionic 3, which is puzzling.