Skip to content

Commit c018d05

Browse files
add more in rsa docs
1 parent 5441972 commit c018d05

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

docs/rsa-CN.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,23 @@ const errorDigest = C.RSA.digest('another message', {hashAlgo: 'md5',});
165165
expect(C.RSA.verify(errorDigest, signature)).toBe(false);
166166
```
167167

168+
### 注意
169+
170+
`initFromKeyFile``generateKeyFile` 的内部实现依赖于 `nodejs``fs`(因为他们就是设计用来从文件中读取,或写入文件的),这意味着他们不能在浏览器中使用。如果在非`nodejs`环境使用他们,我们会报错,但是方法内部所使用的`fs``webpack`中还是可能报错:
171+
172+
```shell
173+
Module not found: Error: Can't resolve 'fs' in '...\node_modules\@originjs\crypto-js-wasm\lib'
174+
```
175+
176+
对于 `webpack > 5`, 你可以在 `webpack.config.js` 中添加如下配置来避免此报错(通过[这个issue](https://github.com/webpack-contrib/css-loader/issues/447)可以查看更多细节):
177+
178+
```javascript
179+
module.exports = {
180+
...
181+
resolve: {
182+
fallback: {
183+
fs: false
184+
},
185+
}
186+
}
187+
```

docs/rsa.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,23 @@ const errorDigest = C.RSA.digest('another message', {hashAlgo: 'md5',});
163163
expect(C.RSA.verify(errorDigest, signature)).toBe(false);
164164
```
165165

166+
### Notes
167+
168+
The implementations of `initFromKeyFile` and `generateKeyFile` depends on `fs` in `nodejs`(as they are designed to read from or write to files), which means they cannot be used in browser. We will throw an error if the runtime is not `nodejs`, but the usage of `fs` still may report in `webpack` like this:
169+
170+
```shell
171+
Module not found: Error: Can't resolve 'fs' in '...\node_modules\@originjs\crypto-js-wasm\lib'
172+
```
173+
174+
For `webpack > 5`, you can add this in your `webpack.config.js` to avoid the error report(check [this issue](https://github.com/webpack-contrib/css-loader/issues/447) for details):
175+
176+
```javascript
177+
module.exports = {
178+
...
179+
resolve: {
180+
fallback: {
181+
fs: false
182+
},
183+
}
184+
}
185+
```

0 commit comments

Comments
 (0)