1

I am not sure this is a SO question but I have been searching for a library similar to keypair or libsignal that allows you to generate public/private keypairs in angular and ionic. I am trying to create an end-to-end encrypted application using angular and ionic on the client side. I have tried Keypair but it comes with a polyfill warning and has not been updated for years. I have also looked at libsignal client for typescript but it looks like a node implementation. Maybe there's another solution to what I am trying to do using angular/ionic. I just want to create a public/private keypair at login or on request...send my public key to the server where others can grab it encrypt a small text and ..save the encrypt text on the server where I can grab in and decrypt in on my client? any suggestions would be greatly appreciated.

TylerH
  • 20,799
  • 66
  • 75
  • 101
MichaelE
  • 757
  • 14
  • 42
  • 1
    Just so you know, one of the flags in SO is precisely *"Asking for recommendations about [...] software libraries"*, so yeah, sorry but this is not an SO question. – S. Dre May 25 '22 at 11:01
  • @S. Dre ....I suspected so.....I will ask a specific question on one of the libs I am trying. – MichaelE May 25 '22 at 15:04
  • Check [Software Engineering Stack Exchange](https://softwareengineering.stackexchange.com/). I see a lot more "which X would you..." type of questions there – S. Dre May 25 '22 at 15:37

1 Answers1

-1

You can use node-forge

rsa_generateKeyPair() {
    let pair = Forge.pki.rsa.generateKeyPair(2048, 0x10001)
    return {
      private: Forge.pki.privateKeyToPem(pair.privateKey),
      public: Forge.pki.publicKeyToPem(pair.publicKey),
    }
}
rsa_decrypt(key:string, data64:string) {
    let privateKey = Forge.pki.privateKeyFromPem(key) ;
    let data = Forge.util.decode64(data64) ;
    return privateKey.decrypt(data) ;
}
rsa_crypt(key:string, data:string) {
    let pubKey = Forge.pki.publicKeyFromPem(key);
    let data64 = Forge.util.encode64(pubKey.encrypt(data)) ;
    return data64 ;
}
Talon
  • 351
  • 1
  • 11
  • I tried to install this before...but it gave some problems....I will get back to it and post the actual issues. – MichaelE Jun 01 '22 at 17:31