function n(t) { return JSON.parse(a("5e5062e82f15fe4ca9d24bc561080e0e",atob(t),0,0,"012345677890123",1)) }
这种 atob 在 js 里面运行为啥报错呢?如何解决?
1
lizheming 2018-07-17 13:11:08 +08:00
atob 是浏览器端方法,Node 中不存在的,需要使用 Buffer.from 方法转一下
```js const btoa = str => Buffer.from(str).toString('base64'); const atob = str => Buffer.from(str, 'base64').toString(); ``` via: https://stackoverflow.com/questions/23097928/node-js-btoa-is-not-defined-error/23097961 |
2
bestehen OP @lizheming function n(t) {
return JSON.parse(a("5e5062e82f15fe4ca9d24bc561080e0e",Buffer.from(t, 'base64').toString(),0,0,"012345677890123",1)) } 我改成这样后,还是报错如下 N = decodeURIComponent(escape(N)) ^ URIError: URI malformed at decodeURIComponent (native) at a (/home/shenjianlin/js/code.js:33:5) at n (/home/shenjianlin/js/code.js:48:19) at Object.<anonymous> (/home/shenjianlin/js/code.js:55:13) at Module._compile (module.js:577:32) at Object.Module._extensions..js (module.js:586:10) at Module.load (module.js:494:32) at tryModuleLoad (module.js:453:12) at Function.Module._load (module.js:445:3) at Module.runMain (module.js:611:10) |