Ionic 3 - Use jsencrypt












1














I'm trying to hash my passwords for login on my Ionic 3 app. I found some tutorial about jsencrypt but it doesn't work and i don't really understand how it work...



Here what i did :



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 = ; // Here there is all my users

constructor(public navCtrl: NavController, public serviceOne: ApiDatabaseService) {
this.serviceOne.getDataUser().subscribe( // I'm calling my api to acces to my database
data => this.Users = data
);
}

public create(name: string): string { // Here the password should be encrypt
let encrypt = new Encrypt.JSEncrypt();
encrypt.setPublicKey(this.pem);
return encrypt.encrypt(name);
};
}


And i have this error :



Typescript Error
Property 'pem' does not exist on type 'LoginPage'.



Also, for Ionic 2 there is many documentation like this : https://docs.ionic.io/services/auth/. But nothing for Ionic 3, why ?










share|improve this question






















  • prem, pem -- typo?
    – Saravana
    Jul 5 '17 at 9:29










  • That's true ...
    – TuxxyDOS
    Jul 5 '17 at 9:30










  • Do you know how it this function work ?
    – TuxxyDOS
    Jul 5 '17 at 9:31






  • 1




    Please check this : stackoverflow.com/questions/44887294/rsa-library-with-angular/…
    – Yatin patel
    Jul 7 '17 at 10:07
















1














I'm trying to hash my passwords for login on my Ionic 3 app. I found some tutorial about jsencrypt but it doesn't work and i don't really understand how it work...



Here what i did :



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 = ; // Here there is all my users

constructor(public navCtrl: NavController, public serviceOne: ApiDatabaseService) {
this.serviceOne.getDataUser().subscribe( // I'm calling my api to acces to my database
data => this.Users = data
);
}

public create(name: string): string { // Here the password should be encrypt
let encrypt = new Encrypt.JSEncrypt();
encrypt.setPublicKey(this.pem);
return encrypt.encrypt(name);
};
}


And i have this error :



Typescript Error
Property 'pem' does not exist on type 'LoginPage'.



Also, for Ionic 2 there is many documentation like this : https://docs.ionic.io/services/auth/. But nothing for Ionic 3, why ?










share|improve this question






















  • prem, pem -- typo?
    – Saravana
    Jul 5 '17 at 9:29










  • That's true ...
    – TuxxyDOS
    Jul 5 '17 at 9:30










  • Do you know how it this function work ?
    – TuxxyDOS
    Jul 5 '17 at 9:31






  • 1




    Please check this : stackoverflow.com/questions/44887294/rsa-library-with-angular/…
    – Yatin patel
    Jul 7 '17 at 10:07














1












1








1







I'm trying to hash my passwords for login on my Ionic 3 app. I found some tutorial about jsencrypt but it doesn't work and i don't really understand how it work...



Here what i did :



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 = ; // Here there is all my users

constructor(public navCtrl: NavController, public serviceOne: ApiDatabaseService) {
this.serviceOne.getDataUser().subscribe( // I'm calling my api to acces to my database
data => this.Users = data
);
}

public create(name: string): string { // Here the password should be encrypt
let encrypt = new Encrypt.JSEncrypt();
encrypt.setPublicKey(this.pem);
return encrypt.encrypt(name);
};
}


And i have this error :



Typescript Error
Property 'pem' does not exist on type 'LoginPage'.



Also, for Ionic 2 there is many documentation like this : https://docs.ionic.io/services/auth/. But nothing for Ionic 3, why ?










share|improve this question













I'm trying to hash my passwords for login on my Ionic 3 app. I found some tutorial about jsencrypt but it doesn't work and i don't really understand how it work...



Here what i did :



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 = ; // Here there is all my users

constructor(public navCtrl: NavController, public serviceOne: ApiDatabaseService) {
this.serviceOne.getDataUser().subscribe( // I'm calling my api to acces to my database
data => this.Users = data
);
}

public create(name: string): string { // Here the password should be encrypt
let encrypt = new Encrypt.JSEncrypt();
encrypt.setPublicKey(this.pem);
return encrypt.encrypt(name);
};
}


And i have this error :



Typescript Error
Property 'pem' does not exist on type 'LoginPage'.



Also, for Ionic 2 there is many documentation like this : https://docs.ionic.io/services/auth/. But nothing for Ionic 3, why ?







angularjs typescript ionic-framework ionic3






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jul 5 '17 at 9:25









TuxxyDOS

80111




80111












  • prem, pem -- typo?
    – Saravana
    Jul 5 '17 at 9:29










  • That's true ...
    – TuxxyDOS
    Jul 5 '17 at 9:30










  • Do you know how it this function work ?
    – TuxxyDOS
    Jul 5 '17 at 9:31






  • 1




    Please check this : stackoverflow.com/questions/44887294/rsa-library-with-angular/…
    – Yatin patel
    Jul 7 '17 at 10:07


















  • prem, pem -- typo?
    – Saravana
    Jul 5 '17 at 9:29










  • That's true ...
    – TuxxyDOS
    Jul 5 '17 at 9:30










  • Do you know how it this function work ?
    – TuxxyDOS
    Jul 5 '17 at 9:31






  • 1




    Please check this : stackoverflow.com/questions/44887294/rsa-library-with-angular/…
    – Yatin patel
    Jul 7 '17 at 10:07
















prem, pem -- typo?
– Saravana
Jul 5 '17 at 9:29




prem, pem -- typo?
– Saravana
Jul 5 '17 at 9:29












That's true ...
– TuxxyDOS
Jul 5 '17 at 9:30




That's true ...
– TuxxyDOS
Jul 5 '17 at 9:30












Do you know how it this function work ?
– TuxxyDOS
Jul 5 '17 at 9:31




Do you know how it this function work ?
– TuxxyDOS
Jul 5 '17 at 9:31




1




1




Please check this : stackoverflow.com/questions/44887294/rsa-library-with-angular/…
– Yatin patel
Jul 7 '17 at 10:07




Please check this : stackoverflow.com/questions/44887294/rsa-library-with-angular/…
– Yatin patel
Jul 7 '17 at 10:07












4 Answers
4






active

oldest

votes


















1














When using the Ionic service your app sends your plain password to the Ionic with service when creating and logging into your account. The auth service will handling all the encryption.



Also, there are no separate docs for Ionic 3 as it is essential the same as Ionic 2 except for some new features and big fixes. There are a few breaking changes but not many. It's not a full rewrite like there was going from Ionic 1 -> Ionic 2 and they are now using semantic versioning so major releases will be more regular similar to Angular.






share|improve this answer































    1














    Change the line



    encrypt.setPublicKey(this.pem);


    To



    encrypt.setPublicKey(this.prem);





    share|improve this answer





























      1














      change



      private prem: string = `my_key`;


      to



      `private pre: string = `my_key`;





      share|improve this answer





























        1














        change the line



        private prem: string = `my_key`;


        to



        private pem: string = `my_key`;





        share|improve this answer





















          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f44922157%2fionic-3-use-jsencrypt%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          4 Answers
          4






          active

          oldest

          votes








          4 Answers
          4






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          When using the Ionic service your app sends your plain password to the Ionic with service when creating and logging into your account. The auth service will handling all the encryption.



          Also, there are no separate docs for Ionic 3 as it is essential the same as Ionic 2 except for some new features and big fixes. There are a few breaking changes but not many. It's not a full rewrite like there was going from Ionic 1 -> Ionic 2 and they are now using semantic versioning so major releases will be more regular similar to Angular.






          share|improve this answer




























            1














            When using the Ionic service your app sends your plain password to the Ionic with service when creating and logging into your account. The auth service will handling all the encryption.



            Also, there are no separate docs for Ionic 3 as it is essential the same as Ionic 2 except for some new features and big fixes. There are a few breaking changes but not many. It's not a full rewrite like there was going from Ionic 1 -> Ionic 2 and they are now using semantic versioning so major releases will be more regular similar to Angular.






            share|improve this answer


























              1












              1








              1






              When using the Ionic service your app sends your plain password to the Ionic with service when creating and logging into your account. The auth service will handling all the encryption.



              Also, there are no separate docs for Ionic 3 as it is essential the same as Ionic 2 except for some new features and big fixes. There are a few breaking changes but not many. It's not a full rewrite like there was going from Ionic 1 -> Ionic 2 and they are now using semantic versioning so major releases will be more regular similar to Angular.






              share|improve this answer














              When using the Ionic service your app sends your plain password to the Ionic with service when creating and logging into your account. The auth service will handling all the encryption.



              Also, there are no separate docs for Ionic 3 as it is essential the same as Ionic 2 except for some new features and big fixes. There are a few breaking changes but not many. It's not a full rewrite like there was going from Ionic 1 -> Ionic 2 and they are now using semantic versioning so major releases will be more regular similar to Angular.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Jul 9 '17 at 15:46

























              answered Jul 9 '17 at 1:17









              Jack

              75911018




              75911018

























                  1














                  Change the line



                  encrypt.setPublicKey(this.pem);


                  To



                  encrypt.setPublicKey(this.prem);





                  share|improve this answer


























                    1














                    Change the line



                    encrypt.setPublicKey(this.pem);


                    To



                    encrypt.setPublicKey(this.prem);





                    share|improve this answer
























                      1












                      1








                      1






                      Change the line



                      encrypt.setPublicKey(this.pem);


                      To



                      encrypt.setPublicKey(this.prem);





                      share|improve this answer












                      Change the line



                      encrypt.setPublicKey(this.pem);


                      To



                      encrypt.setPublicKey(this.prem);






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Feb 22 at 17:08









                      Che'-Andre Gordon

                      311




                      311























                          1














                          change



                          private prem: string = `my_key`;


                          to



                          `private pre: string = `my_key`;





                          share|improve this answer


























                            1














                            change



                            private prem: string = `my_key`;


                            to



                            `private pre: string = `my_key`;





                            share|improve this answer
























                              1












                              1








                              1






                              change



                              private prem: string = `my_key`;


                              to



                              `private pre: string = `my_key`;





                              share|improve this answer












                              change



                              private prem: string = `my_key`;


                              to



                              `private pre: string = `my_key`;






                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Jun 4 at 14:29









                              zouhair

                              867




                              867























                                  1














                                  change the line



                                  private prem: string = `my_key`;


                                  to



                                  private pem: string = `my_key`;





                                  share|improve this answer


























                                    1














                                    change the line



                                    private prem: string = `my_key`;


                                    to



                                    private pem: string = `my_key`;





                                    share|improve this answer
























                                      1












                                      1








                                      1






                                      change the line



                                      private prem: string = `my_key`;


                                      to



                                      private pem: string = `my_key`;





                                      share|improve this answer












                                      change the line



                                      private prem: string = `my_key`;


                                      to



                                      private pem: string = `my_key`;






                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Nov 21 at 7:16









                                      Siundu254

                                      114




                                      114






























                                          draft saved

                                          draft discarded




















































                                          Thanks for contributing an answer to Stack Overflow!


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.





                                          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                          Please pay close attention to the following guidance:


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.




                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function () {
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f44922157%2fionic-3-use-jsencrypt%23new-answer', 'question_page');
                                          }
                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          Feedback on college project

                                          Albești (Vaslui)

                                          Futebolista