This article will introduce to you how to use the jsencrypt plug-in in angular. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
Related recommendations: "angular tutorial"
angular uses the jsencrypt plug-in
1. First install the jsencrypt module
npm install --save jsencrypt
in the angular project 2. Introduce and use
import * as JsEncryptModule from 'jsencrypt'; export class RsaUtil { constructor() { } public getSignStr(timestr: string) { let publicKey = '-----BEGIN PUBLIC KEY-----公钥-----END PUBLIC KEY-----'; let privateStr = "自定义的加密串"; let encrypt = new JsEncryptModule.JSEncrypt(); console.log(encrypt); encrypt.setPublicKey(publicKey); let signature = encrypt.encrypt(privateStr + timestr); console.log(signature); return signature; } }
For more programming-related knowledge, please visit: Programming Learning! !
The above is the detailed content of Detailed explanation of how to use the jsencrypt plug-in in angular. For more information, please follow other related articles on the PHP Chinese website!