JSPM

sm4utilpm

1.0.1
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 6
    • Score
      100M100P100Q32516F
    • License ISC

    在git@github.com:BubblingXuYijie/SM4Util.git的SM4基础上优化的版本

    Package Exports

    • sm4utilpm
    • sm4utilpm/sm4.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sm4utilpm) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

     * 调用方法:
     * 引入
      import {SM4Util} from "sm4utilpm";
      const sm4 = new SM4Util();
    
     * 不使用自定义 secretKey,一般用于前端自行加解密,如果是前端加密后端解密,则需要自定义secretKey,前后端一致才能正确解密
      sm4.encryptDefault_ECB('123456');
      sm4.decryptDefault_ECB('123456');
     * secretKey必须为16位字符串,可包含字母数字标点,不能包含非法字符
      sm4.encryptCustom_ECB('123456', 'asdfghjklmnbvcx,');
      sm4.decryptCustom_ECB('123456', 'asdfghjklmnbvcx,');
     
     * CBC 加密模式(更加安全),需要两个密钥
      sm4.encryptDefault_CBC('123456');
      sm4.decryptDefault_CBC('123456');
     * 同样可以自定义 secretKey 和 iv,需要两个密钥前后端都一致,secretKey和iv必须为16位字符串,可包含字母数字标点,不能包含非法字符
      sm4.encryptCustom_CBC('123456', 'asdfghjklmnbvcx,', 'mnbvcxzpoiuytre1');
      sm4.decryptCustom_CBC('123456', 'asdfghjklmnbvcx,', 'mnbvcxzpoiuytre1');

    tips

    • 在原有sm4util基础上,优化了加解密sm4_crypt_ecb,sm4_crypt_cbcconcat方法,concat方法在处理大数据量时,因每次执行都产生新对象, 性能较差。