VIVEK
VIVEK

Reputation: 297

How to Encrypt Password with public key in angular and Decrypt the password with private key in C#

I am stuck into a task where I want to Encrypt the user password with RSA public key into Angular 7 and same decrypt with private key into C# Please help me into this task Many many thanks in advance.

Upvotes: 1

Views: 6216

Answers (2)

Aneeq Rehman
Aneeq Rehman

Reputation: 11

node-forge can be used at angular

 import * as Forge from 'node-forge';

 encryptWithPublicKey(valueToEncrypt: string): string {
  
    const rsa = Forge.pki.publicKeyFromPem(this.publicKey);
    const encryptedBytes = rsa.encrypt(valueToEncrypt.toString(),'RSAES-PKCS1-V1_5');
    return window.btoa(encryptedBytes)
  }
} 

Upvotes: 0

VIVEK
VIVEK

Reputation: 297

Here are some Link which are help full in this task:

Below libs are helpful in generating RSA Asymmetric Encryption:(Angular)

node-rsa: https://www.npmjs.com/package/node-rsa
quick-encrypt: https://www.npmjs.com/package/quick-encrypt
asymmetric-crypto: https://www.npmjs.com/package/asymmetric-crypto

Upvotes: 2

Related Questions