wechat-miniprogram / sm-crypto

miniprogram sm crypto library
MIT License
441 stars 88 forks source link

sm3杂凑运算耗时 #19

Closed zcmain closed 3 years ago

zcmain commented 3 years ago

使用sm3对超过400kb数据进行杂凑运算耗时大约为20秒左右,而且内存暴增

const sm3 = require('miniprogram-sm-crypto').sm3;

export default class HashUtil {
  /**
   * SM3杂凑算法
   * @param _data     要进行杂凑运算数据
   * @return hashHex  32字节hash值
   */
  public static hashBySM3(_data: string): string {
    const startTime = new Date().getTime();
    const data = sm3(_data);
    console.log('----->SM3消耗时间 :' + (new Date().getTime() - startTime) + '(ms)');
    return data;
  }
}
------>SM3消耗时间: 21033 (ms)
JuneAndGreen commented 3 years ago

0.2.7 版本做了下优化,可以试试