RSA library with angular

前端 未结 3 543
逝去的感伤
逝去的感伤 2020-12-06 21:07

Hello I am trying to implement encryption in my application. I am using angular (angular-4) for the frontend and node js for the backend. Communication is done through socke

3条回答
  •  无人及你
    2020-12-06 21:18

    What you can do if you want to stay with the very good node-rsa library it to eject ng-cli from your project and configure webpack to automatically polyfill the nodejs crypto module with the crypto-browserify library.

    First, eject ng-cli from your project (you will need to run yarn build or npm run build to build your project and you won't be able anymore to use ng build) :

    ng eject
    

    Then you need to add this data to the webpack.config.js file created by the ejection process :

    "node": {
        ...
        "crypto": true,
        ...
    }
    

    This will tell webpack to polyfill the crypto module.

    I will soon dive into how to keep ng-cli and have a correct polyfilling behavior...

提交回复
热议问题