Comparing version 0.2.4 to 0.2.5
@@ -0,1 +1,5 @@ | ||
## 0.2.5 | ||
* sm3 支持字节数组输入 | ||
## 0.2.4 | ||
@@ -2,0 +6,0 @@ |
@@ -1,1 +0,1 @@ | ||
window.sm3=function(n){function r(o){if(t[o])return t[o].exports;var u=t[o]={i:o,l:!1,exports:{}};return n[o].call(u.exports,u,u.exports,r),u.l=!0,u.exports}var t={};return r.m=n,r.c=t,r.d=function(n,t,o){r.o(n,t)||Object.defineProperty(n,t,{configurable:!1,enumerable:!0,get:o})},r.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(t,"a",t),t},r.o=function(n,r){return Object.prototype.hasOwnProperty.call(n,r)},r.p="",r(r.s=7)}({7:function(n,r,t){"use strict";function o(n,r){return n.length>=r?n:new Array(r-n.length+1).join("0")+n}function u(n){for(var r="",t=0;t<n.length/8;t++)r+=o(parseInt(n.substr(8*t,8),2).toString(16),2);return r}function e(n){for(var r="",t=0;t<n.length/2;t++)r+=o(parseInt(n.substr(2*t,2),16).toString(2),8);return r}function i(n){for(var r="",t=0,u=n.length;t<u;t++){var e=n.codePointAt(t);if(e<=127)r+=o(e.toString(2),8);else if(e<=2047)r+=o((192|e>>>6).toString(2),8),r+=o((128|63&e).toString(2),8);else if(e<=55295||e>=57344&&e<=65535)r+=o((224|e>>>12).toString(2),8),r+=o((128|e>>>6&63).toString(2),8),r+=o((128|63&e).toString(2),8);else{if(!(e>=65536&&e<=1114111))throw r+=o(e.toString(2),8),new Error("input is not supported");t++,r+=o((240|e>>>18&28).toString(2),8),r+=o((128|e>>>12&63).toString(2),8),r+=o((128|e>>>6&63).toString(2),8),r+=o((128|63&e).toString(2),8)}}return r}function f(n,r){return n.substring(r%n.length)+n.substr(0,r%n.length)}function c(n,r,t){for(var o=n||"",u=r||"",e=[],i=void 0,f=o.length-1;f>=0;f--)i=t(o[f],u[f],i),e[f]=i[0];return e.join("")}function s(n,r){return c(n,r,function(n,r){return[n===r?"0":"1"]})}function a(n,r){return c(n,r,function(n,r){return["1"===n&&"1"===r?"1":"0"]})}function g(n,r){return c(n,r,function(n,r){return["1"===n||"1"===r?"1":"0"]})}function l(n,r){return c(n,r,function(n,r,t){var o=t?t[1]:"0";return n!==r?["0"===o?"1":"0",o]:[o,n]})}function v(n){return c(n,void 0,function(n){return["1"===n?"0":"1"]})}function d(n){return function(){for(var r=arguments.length,t=Array(r),o=0;o<r;o++)t[o]=arguments[o];return t.reduce(function(r,t){return n(r,t)})}}function p(n){return d(s)(n,f(n,9),f(n,17))}function b(n){return d(s)(n,f(n,15),f(n,23))}function h(n,r,t,o){return o>=0&&o<=15?d(s)(n,r,t):d(g)(a(n,r),a(n,t),a(r,t))}function S(n,r,t,o){return o>=0&&o<=15?d(s)(n,r,t):g(a(n,r),a(v(n),t))}function w(n){return e(n>=0&&n<=15?"79cc4519":"7a879d8a")}function x(n,r){for(var t=[],o=[],u=0;u<16;u++)t.push(r.substr(32*u,32));for(var e=16;e<68;e++)t.push(d(s)(b(d(s)(t[e-16],t[e-9],f(t[e-3],15))),f(t[e-13],7),t[e-6]));for(var i=0;i<64;i++)o.push(s(t[i],t[i+4]));for(var c=[],a=0;a<8;a++)c.push(n.substr(32*a,32));for(var g=c[0],v=c[1],x=c[2],j=c[3],y=c[4],m=c[5],A=c[6],O=c[7],P=void 0,I=void 0,_=void 0,E=void 0,M=0;M<64;M++)P=f(d(l)(f(g,12),y,f(w(M),M)),7),I=s(P,f(g,12)),_=d(l)(h(g,v,x,M),j,I,o[M]),E=d(l)(S(y,m,A,M),O,P,t[M]),j=x,x=f(v,9),v=g,g=_,O=A,A=f(m,19),m=y,y=p(E);return s([g,v,x,j,y,m,A,O].join(""),n)}n.exports=function(n){var r=i(n),t=r.length,f=t%512;f=f>=448?512-f%448-1:448-f-1;for(var c=(r+"1"+o("",f)+o(t.toString(2),64)).toString(),s=(t+f+65)/512,a=e("7380166f4914b2b9172442d7da8a0600a96f30bc163138aae38dee4db0fb0e4e"),g=0;g<=s-1;g++){a=x(a,c.substr(512*g,512))}return u(a)}}}); | ||
window.sm3=function(n){function r(o){if(t[o])return t[o].exports;var u=t[o]={i:o,l:!1,exports:{}};return n[o].call(u.exports,u,u.exports,r),u.l=!0,u.exports}var t={};return r.m=n,r.c=t,r.d=function(n,t,o){r.o(n,t)||Object.defineProperty(n,t,{configurable:!1,enumerable:!0,get:o})},r.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(t,"a",t),t},r.o=function(n,r){return Object.prototype.hasOwnProperty.call(n,r)},r.p="",r(r.s=7)}({7:function(n,r,t){"use strict";function o(n,r){return n.length>=r?n:new Array(r-n.length+1).join("0")+n}function u(n){for(var r="",t=0;t<n.length/8;t++)r+=o(parseInt(n.substr(8*t,8),2).toString(16),2);return r}function e(n){for(var r="",t=0;t<n.length/2;t++)r+=o(parseInt(n.substr(2*t,2),16).toString(2),8);return r}function i(n){for(var r="",t=0,u=n.length;t<u;t++){var e=n.codePointAt(t);if(e<=127)r+=o(e.toString(2),8);else if(e<=2047)r+=o((192|e>>>6).toString(2),8),r+=o((128|63&e).toString(2),8);else if(e<=55295||e>=57344&&e<=65535)r+=o((224|e>>>12).toString(2),8),r+=o((128|e>>>6&63).toString(2),8),r+=o((128|63&e).toString(2),8);else{if(!(e>=65536&&e<=1114111))throw r+=o(e.toString(2),8),new Error("input is not supported");t++,r+=o((240|e>>>18&28).toString(2),8),r+=o((128|e>>>12&63).toString(2),8),r+=o((128|e>>>6&63).toString(2),8),r+=o((128|63&e).toString(2),8)}}return r}function f(n){return n.reduce(function(n,r){return n+o(r.toString(2),8)},"")}function c(n,r){return n.substring(r%n.length)+n.substr(0,r%n.length)}function s(n,r,t){for(var o=n||"",u=r||"",e=[],i=void 0,f=o.length-1;f>=0;f--)i=t(o[f],u[f],i),e[f]=i[0];return e.join("")}function a(n,r){return s(n,r,function(n,r){return[n===r?"0":"1"]})}function g(n,r){return s(n,r,function(n,r){return["1"===n&&"1"===r?"1":"0"]})}function l(n,r){return s(n,r,function(n,r){return["1"===n||"1"===r?"1":"0"]})}function v(n,r){return s(n,r,function(n,r,t){var o=t?t[1]:"0";return n!==r?["0"===o?"1":"0",o]:[o,n]})}function d(n){return s(n,void 0,function(n){return["1"===n?"0":"1"]})}function p(n){return function(){for(var r=arguments.length,t=Array(r),o=0;o<r;o++)t[o]=arguments[o];return t.reduce(function(r,t){return n(r,t)})}}function b(n){return p(a)(n,c(n,9),c(n,17))}function h(n){return p(a)(n,c(n,15),c(n,23))}function S(n,r,t,o){return o>=0&&o<=15?p(a)(n,r,t):p(l)(g(n,r),g(n,t),g(r,t))}function w(n,r,t,o){return o>=0&&o<=15?p(a)(n,r,t):l(g(n,r),g(d(n),t))}function x(n){return e(n>=0&&n<=15?"79cc4519":"7a879d8a")}function y(n,r){for(var t=[],o=[],u=0;u<16;u++)t.push(r.substr(32*u,32));for(var e=16;e<68;e++)t.push(p(a)(h(p(a)(t[e-16],t[e-9],c(t[e-3],15))),c(t[e-13],7),t[e-6]));for(var i=0;i<64;i++)o.push(a(t[i],t[i+4]));for(var f=[],s=0;s<8;s++)f.push(n.substr(32*s,32));for(var g=f[0],l=f[1],d=f[2],y=f[3],j=f[4],m=f[5],A=f[6],O=f[7],P=void 0,I=void 0,_=void 0,E=void 0,M=0;M<64;M++)P=c(p(v)(c(g,12),j,c(x(M),M)),7),I=a(P,c(g,12)),_=p(v)(S(g,l,d,M),y,I,o[M]),E=p(v)(w(j,m,A,M),O,P,t[M]),y=d,d=c(l,9),l=g,g=_,O=A,A=c(m,19),m=j,j=b(E);return a([g,l,d,y,j,m,A,O].join(""),n)}n.exports=function(n){var r="string"==typeof n?i(n):f(n),t=r.length,c=t%512;c=c>=448?512-c%448-1:448-c-1;for(var s=(r+"1"+o("",c)+o(t.toString(2),64)).toString(),a=(t+c+65)/512,g=e("7380166f4914b2b9172442d7da8a0600a96f30bc163138aae38dee4db0fb0e4e"),l=0;l<=a-1;l++){g=y(g,s.substr(512*l,512))}return u(g)}}}); |
{ | ||
"name": "sm-crypto", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "sm-crypto", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -73,2 +73,9 @@ /** | ||
/** | ||
* 数组转为二进制 | ||
*/ | ||
function array2binary(arr) { | ||
return arr.reduce((temp, item) => temp + leftPad(item.toString(2), 8), '') | ||
} | ||
/** | ||
* 循环左移 | ||
@@ -240,3 +247,3 @@ */ | ||
module.exports = function (str) { | ||
const binary = str2binary(str) | ||
const binary = typeof str === 'string' ? str2binary(str) : array2binary(str) | ||
@@ -243,0 +250,0 @@ // 填充 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
111446
1820