{"versions":{"0.0.2":{"name":"gm-crypt","version":"0.0.2","description":"Chinese GM crypt algorithm in JavaScript","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+ssh://git@github.com/pecliu/gm-crypt.git"},"keywords":["ChineseGM","SM2","SM3","SM4"],"author":{"name":"pecliu","email":"pecliu@foxmail.com"},"license":"MIT","dependencies":{"base64-js":"^1.3.0"},"devDependencies":{"standard":"^12.0.1"},"gitHead":"3080c93b560bd4892217e591fa78bfc810f20aee","bugs":{"url":"https://github.com/pecliu/gm-crypt/issues"},"homepage":"https://github.com/pecliu/gm-crypt#readme","_id":"gm-crypt@0.0.2","_npmVersion":"6.4.1","_nodeVersion":"8.12.0","_npmUser":{"name":"anonymous","email":"pecliu@foxmail.com"},"dist":{"shasum":"da2633fe86ff6d41551d1f78b78cb7aace583ce5","size":6070,"noattachment":false,"tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/gm-crypt/-/gm-crypt-0.0.2.tgz"},"maintainers":[{"name":"anonymous","email":"pecliu@foxmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/gm-crypt_0.0.2_1541985930407_0.021602176983614996"},"_hasShrinkwrap":false,"publish_time":1541985930549,"_cnpm_publish_time":1541985930549,"contributors":[]}},"dist-tags":{"latest":"0.0.2"},"name":"gm-crypt","time":{"modified":"2023-08-02T02:42:41.783Z","created":"2022-01-26T20:09:22.459Z","0.0.2":"2018-11-12T01:25:30.549Z","0.0.1":"2018-11-09T11:09:11.881Z"},"readme":"# gm-crypt-nodejs \n\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) \n\n基于`javascript`和JS的[`TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)的国密加密算法实现。\n\nImplement of Chinese encrypt algorithm in JavaScript and [TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray).\n\n为了兼容浏览器环境和node.je环境，这里我们使用了[TextEncoder](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder)和[Base64.js](https://github.com/beatgammit/base64-js)。\n\nHere we use [TextEncoder](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder) and [Base64.js](https://github.com/beatgammit/base64-js) for both browser ande node.js environment.\n\n由于使用了`TextEncoder`，所以暂时不支持`Edge`。Node.js版本最低为8，建议使用最新的LTS版本。\n\nBecause of using `TextEncoder`， this code cannot run in `Edge` browser. `Node.js`‘s version should at least be 8, and the newest LTS version is recommended.\n\n## Roadmap\n\n- [x] SM4\n- [ ] SM3\n- [ ] SM2\n\n## Documentation\n\n### Install\n\n```\nnpm install gm-crypt\n```\n\n### SM4\n\n#### Init\n\n```js\nconst SM4 = require('gm-crypt').sm4\n\nlet sm4Config = {\n  // encrypt/decypt main key; cannot be omitted\n  key: 'JeF8U9wHFOMfs2Y8',\n\n  // optional; can be 'cbc' or 'ecb'\n  mode: 'cbc', // default\n\n  // optional; when use cbc mode, it's \bnecessary\n  iv: 'UISwD9fW6cFh9SNS', // default is null\n\n  // optional: this is the cipher data's type; Can be 'base64' or 'text'\n  cipherType: 'base64' // default is base64\n}\n\nlet sm4 = new SM4(sm4Config)\n```\n\n#### Encrypt\n\n```js\nlet plaintext = '中国国密加解密算法'\nlet ciphertext = sm4.encrypt(plaintext)\n// ciphertext's result is 'j/+HgSpv8RZQI2YtSq0L1RnemiSokMm1VvLHSTt245U='\n```\n\n#### Decrypt\n\n```js\nlet ciphertext = 'j/+HgSpv8RZQI2YtSq0L1RnemiSokMm1VvLHSTt245U='\nlet plaintext = sm4.decrypt(ciphertext)\n// plaintext's result is '中国国密加解密算法'\n```\n\n\n## License\n\n[MIT](LICENSE)","users":{}}