首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在角7中使用SJCL时,无法解析“./node_modules/SJCL”中的“crypto”

在角7中使用SJCL时,无法解析“./node_modules/SJCL”中的“crypto”
EN

Stack Overflow用户
提问于 2019-03-29 07:30:26
回答 1查看 3.8K关注 0票数 0

我想在客户端加密数据,所以我找到了SJCL npm。

翻阅了他们的文件。然而,SJCL贡献者提供的文档较少,无法在ar角中实现这一点。

我试过以下几种方法。

我安装了软件包

  1. npm安装--保存sjcl 之后,我尝试安装类型定义。
  2. npm安装--保存sjcl @type/sjcl

这是我的package.json

代码语言:javascript
复制
{

"name": "project-name",

"version": "0.0.0",


  "scripts": {

    "ng": "ng",

    "start": "ng serve",

    "build": "ng build",

    "test": "ng test",

    "lint": "ng lint",

    "e2e": "ng e2e"

  },

  "private": true,

  "dependencies": {

    "@angular/animations": "~7.1.0",

    "@angular/cdk": "~7.1.0",

    "@angular/common": "~7.1.0",

    "@angular/compiler": "~7.1.0",

    "@angular/core": "~7.1.0",

    "@angular/forms": "~7.1.0",

    "@angular/platform-browser": "~7.1.0",

    "@angular/platform-browser-dynamic": "~7.1.0",

    "@angular/router": "~7.1.0",

    "@types/axios": "^0.14.0",

    "@types/sjcl": "^1.0.28",

    "angular-filepond": "^1.0.5",

    "core-js": "^2.5.4",

    "rxjs": "~6.3.3",

    "sjcl": "^1.0.8",

    "tslib": "^1.9.0",

    "zone.js": "~0.8.26"

  },

  "devDependencies": {

    "@angular-devkit/build-angular": "~0.11.0",

    "@angular/cli": "~7.1.2",

    "@angular/compiler-cli": "~7.1.0",

    "@angular/language-service": "~7.1.0",

    "@schematics/angular": "~7.1.0",

    "@types/echarts": "^4.1.3",

    "@types/jasmine": "~2.8.8",

    "@types/jasminewd2": "~2.0.3",

    "@types/node": "^8.9.5",

    "codelyzer": "~4.5.0",

    "jasmine-core": "~2.99.1",

    "jasmine-spec-reporter": "~4.2.1",

    "karma": "~3.1.1",

    "karma-chrome-launcher": "~2.2.0",

    "karma-coverage-istanbul-reporter": "~2.0.1",

    "karma-jasmine": "~1.1.2",

    "karma-jasmine-html-reporter": "^0.2.2",

    "protractor": "~5.4.0",

    "ts-node": "~7.0.0",

    "tslint": "~5.11.0",

    "typescript": "~3.1.6"

  }
}

我也做过这件事

代码语言:javascript
复制
import * as sjcl from 'sjcl';

在我的部件里。

此外,我已经通过了这个链接Using SJCL library in Angular2

当我运行角应用程序时,我

代码语言:javascript
复制
** WARNING in ./node_modules/sjcl/sjcl.js
Module not found: Error: Can't resolve 'crypto' in './node_modules/sjcl'**


**Note starts:**

used sjcl.encrypt("password", "data")
but after console.log(sjcl.encrypt("password", "data"))
it shows undefined

**Note ends:**

可能是我的笔记,不是那么完美,或者我定义错了。如何在没有此警告的情况下使用SJCL加密数据?

EN

回答 1

Stack Overflow用户

发布于 2020-03-04 19:26:03

我使用了sjcl库作为我的react应用程序。但这一过程保持不变。

代码语言:javascript
复制
import sjcl from 'sjcl';

现在您可以使用sjcl.encrypt()函数了。如果您正在寻找一些AES加密的示例,您可以看到我的详细答案https://stackoverflow.com/a/60504619/6453913

您也可以使用传统的通用use方法。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55412462

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档