!function(r,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.sm3=n():r.sm3=n()}("undefined"!=typeof self?self:this,function(){return function(r){function n(e){if(t[e])return t[e].exports;var o=t[e]={i:e,l:!1,exports:{}};return r[e].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var t={};return n.m=r,n.c=t,n.d=function(r,t,e){n.o(r,t)||Object.defineProperty(r,t,{configurable:!1,enumerable:!0,get:e})},n.n=function(r){var t=r&&r.__esModule?function(){return r.default}:function(){return r};return n.d(t,"a",t),t},n.o=function(r,n){return Object.prototype.hasOwnProperty.call(r,n)},n.p="",n(n.s=6)}({1:function(r,n,t){"use strict";function e(r,n){for(var t=[],e=~~(n/8),o=n%8,u=0,i=r.length;u<i;u++)t[u]=(r[(u+e)%i]<<o&255)+(r[(u+e+1)%i]>>>8-o&255);return t}function o(r,n){for(var t=[],e=r.length-1;e>=0;e--)t[e]=255&(r[e]^n[e]);return t}function u(r,n){for(var t=[],e=r.length-1;e>=0;e--)t[e]=r[e]&n[e]&255;return t}function i(r,n){for(var t=[],e=r.length-1;e>=0;e--)t[e]=255&(r[e]|n[e]);return t}function f(r,n){for(var t=[],e=0,o=r.length-1;o>=0;o--){var u=r[o]+n[o]+e;u>255?(e=1,t[o]=255&u):(e=0,t[o]=255&u)}return t}function s(r){for(var n=[],t=r.length-1;t>=0;t--)n[t]=255&~r[t];return n}function c(r){return o(o(r,e(r,9)),e(r,17))}function a(r){return o(o(r,e(r,15)),e(r,23))}function l(r,n,t,e){return e>=0&&e<=15?o(o(r,n),t):i(i(u(r,n),u(r,t)),u(n,t))}function p(r,n,t,e){return e>=0&&e<=15?o(o(r,n),t):i(u(r,n),u(s(r),t))}function h(r,n){for(var t=[],u=[],i=0;i<16;i++){var s=4*i;t.push(n.slice(s,s+4))}for(var h=16;h<68;h++)t.push(o(o(a(o(o(t[h-16],t[h-9]),e(t[h-3],15))),e(t[h-13],7)),t[h-6]));for(var v=0;v<64;v++)u.push(o(t[v],t[v+4]));for(var g=[121,204,69,25],d=[122,135,157,138],y=r.slice(0,4),m=r.slice(4,8),w=r.slice(8,12),x=r.slice(12,16),b=r.slice(16,20),j=r.slice(20,24),A=r.slice(24,28),E=r.slice(28,32),I=void 0,O=void 0,P=void 0,k=void 0,S=0;S<64;S++){var _=S>=0&&S<=15?g:d;I=e(f(f(e(y,12),b),e(_,S)),7),O=o(I,e(y,12)),P=f(f(f(l(y,m,w,S),x),O),u[S]),k=f(f(f(p(b,j,A,S),E),I),t[S]),x=w,w=e(m,9),m=y,y=P,E=A,A=e(j,19),j=b,b=c(k)}return o([].concat(y,m,w,x,b,j,A,E),r)}function v(r){var n=8*r.length,t=n%512;t=t>=448?512-t%448-1:448-t-1;for(var e=new Array((t-7)/8),o=0,u=e.length;o<u;o++)e[o]=0;var i=[];n=n.toString(2);for(var f=7;f>=0;f--)if(n.length>8){var s=n.length-8;i[f]=parseInt(n.substr(s),2),n=n.substr(0,s)}else n.length>0?(i[f]=parseInt(n,2),n=""):i[f]=0;for(var c=[].concat(r,[128],e,i),a=c.length/64,l=[115,128,22,111,73,20,178,185,23,36,66,215,218,138,6,0,169,111,48,188,22,49,56,170,227,141,238,77,176,251,14,78],p=0;p<a;p++){var v=64*p;l=h(l,c.slice(v,v+64))}return l}function g(r,n){for(n.length>d&&(n=v(n));n.length<d;)n.push(0);var t=o(n,y),e=t.concat(r);return e=v(e),e=o(n,m).concat(e),e=v(e)}for(var d=64,y=new Array(d),m=new Array(d),w=0;w<d;w++)y[w]=54,m[w]=92;r.exports={sm3:v,hmac:g}},6:function(r,n,t){"use strict";function e(r,n){return r.length>=n?r:new Array(n-r.length+1).join("0")+r}function o(r){return r.map(function(r){return r=r.toString(16),1===r.length?"0"+r:r}).join("")}function u(r){var n=[],t=r.length;t%2!=0&&(r=e(r,t+1)),t=r.length;for(var o=0;o<t;o+=2)n.push(parseInt(r.substr(o,2),16));return n}function i(r){for(var n=[],t=0,e=r.length;t<e;t++){var o=r.codePointAt(t);if(o<=127)n.push(o);else if(o<=2047)n.push(192|o>>>6),n.push(128|63&o);else if(o<=55295||o>=57344&&o<=65535)n.push(224|o>>>12),n.push(128|o>>>6&63),n.push(128|63&o);else{if(!(o>=65536&&o<=1114111))throw n.push(o),new Error("input is not supported");t++,n.push(240|o>>>18&28),n.push(128|o>>>12&63),n.push(128|o>>>6&63),n.push(128|63&o)}}return n}var f=t(1),s=f.sm3,c=f.hmac;r.exports=function(r,n){if(r="string"==typeof r?i(r):Array.prototype.slice.call(r),n){if("hmac"!==(n.mode||"hmac"))throw new Error("invalid mode");var t=n.key;if(!t)throw new Error("invalid key");return t="string"==typeof t?u(t):Array.prototype.slice.call(t),o(c(r,t))}return o(s(r))}}})});