Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/emmansun/sm4js
A Simple Pure JavaScript GM-Standards SM2 SM3 SM4 Implementation
https://github.com/emmansun/sm4js
sjcl sm2 sm3 sm4
Last synced: 3 days ago
JSON representation
A Simple Pure JavaScript GM-Standards SM2 SM3 SM4 Implementation
- Host: GitHub
- URL: https://github.com/emmansun/sm4js
- Owner: emmansun
- License: mit
- Created: 2024-04-02T00:07:18.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-06-07T10:01:35.000Z (5 months ago)
- Last Synced: 2024-08-08T18:39:10.086Z (3 months ago)
- Topics: sjcl, sm2, sm3, sm4
- Language: JavaScript
- Homepage:
- Size: 548 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sm4js (sjcl-sm)
[![SM4JS CI](https://github.com/emmansun/sm4js/actions/workflows/ci.yml/badge.svg)](https://github.com/emmansun/sm4js/actions/workflows/ci.yml)
[![npm version](https://badge.fury.io/js/gmsm-sm4js.svg)](https://badge.fury.io/js/gmsm-sm4js)
[![NPM Downloads][npm-downloads-image]][npm-url]**A Simple Pure JavaScript GM-Standards SM2/SM3/SM4 Implementation based on [sjcl](https://github.com/bitwiseshiftleft/sjcl).**
扩展sjcl实现的优势在于其丰富的对称加密模式实现,以及其简洁的代码、较好的性能。“缺点”在于其缺乏CSR、CERT等高级功能支持。您也可以参考另外一个实现:[jsrsasign-sm](https://github.com/emmansun/sm2js)。
## SM2
- 加解密
- 签名、验签
- 密钥交换具体使用方法,请参考[sm2_test.js](https://github.com/emmansun/sm4js/blob/master/test/sm2_test.js "sm2_test.js")
## 公私钥处理
- PKIX EC公钥解析、构造
- SEC1 EC私钥解析、构造
- PKCS#8私钥解析、构造(不加密)
- PKCS#8私钥解析、构造(加密)。支持PBES2/PBKDF2,HMAC HASH支持SHA1/SHA256/SHA512/SM3,加解密支持SM4/AES,加密模式支持CBC/GCM## SM3
位于**sjcl.hash.sm3**中,使用方式和其它哈希算法相同。具体使用方法,请参考[sm3_test.js](https://github.com/emmansun/sm4js/blob/master/test/sm3_test.js "sm3_test.js")## SM4
位于**sjcl.cipher.sm4**中,使用方式和AES相同。具体使用方法,请参考[sm4_test.js](https://github.com/emmansun/sm4js/blob/master/test/sm4_test.js "sm4_test.js")如果是NodeJS的后端应用,请直接使用NodeJS提供的SM4实现(基于OpenSSL)。NodeJS目前尚未支持SM4-GCM模式,请参考[一种使用nodejs SM4-ECB和sjcl gcm的SM4-GCM实现](https://gist.github.com/emmansun/2eb37257cfe6ed561d1668f720f51030)。
[npm-downloads-image]: https://badgen.net/npm/dm/gmsm-sm4js
[npm-url]: https://npmjs.org/package/gmsm-sm4js