Home  >  Article  >  Web Front-end  >  Detailed explanation of how to use the jsencrypt plug-in in angular

Detailed explanation of how to use the jsencrypt plug-in in angular

青灯夜游
青灯夜游forward
2020-12-15 18:01:113534browse

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.

Detailed explanation of how to use the jsencrypt plug-in in angular

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!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete