Home > Web Front-end > JS Tutorial > body text

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

青灯夜游
Release: 2021-02-22 17:56:13
forward
3470 people have browsed it

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
Copy after login

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;
    }
 
}
Copy after login

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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!