Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sm-crypto

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sm-crypto - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

1

.eslintrc.js

@@ -86,2 +86,3 @@ module.exports = {

'max-len': 'off',
'no-bitwise': 'off',
},

@@ -88,0 +89,0 @@ 'globals': {

@@ -0,1 +1,5 @@

## 0.2.2
* sm3 支持中文输入
## 0.2.1

@@ -2,0 +6,0 @@

2

dist/sm3.js

@@ -1,1 +0,1 @@

window.sm3=function(n){function r(u){if(t[u])return t[u].exports;var e=t[u]={i:u,l:!1,exports:{}};return n[u].call(e.exports,e,e.exports,r),e.l=!0,e.exports}var t={};return r.m=n,r.c=t,r.d=function(n,t,u){r.o(n,t)||Object.defineProperty(n,t,{configurable:!1,enumerable:!0,get:u})},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 u(n,r){return n.length>=r?n:new Array(r-n.length+1).join("0")+n}function e(n){for(var r="",t=0;t<n.length/8;t++)r+=u(parseInt(n.substr(8*t,8),2).toString(16),2);return r}function o(n){for(var r="",t=0;t<n.length/2;t++)r+=u(parseInt(n.substr(2*t,2),16).toString(2),8);return r}function i(n){for(var r="",t=0,e=n.length;t<e;t++){r+=u(n[t].codePointAt(0).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 u=n||"",e=r||"",o=[],i=void 0,f=u.length-1;f>=0;f--)i=t(u[f],e[f],i),o[f]=i[0];return o.join("")}function a(n,r){return c(n,r,function(n,r){return[n===r?"0":"1"]})}function s(n,r){return c(n,r,function(n,r){return["1"===n&&"1"===r?"1":"0"]})}function v(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 u=t?t[1]:"0";return n!==r?["0"===u?"1":"0",u]:[u,n]})}function d(n){return c(n,void 0,function(n){return["1"===n?"0":"1"]})}function g(n){return function(){for(var r=arguments.length,t=Array(r),u=0;u<r;u++)t[u]=arguments[u];return t.reduce(function(r,t){return n(r,t)})}}function p(n){return g(a)(n,f(n,9),f(n,17))}function b(n){return g(a)(n,f(n,15),f(n,23))}function h(n,r,t,u){return u>=0&&u<=15?g(a)(n,r,t):g(v)(s(n,r),s(n,t),s(r,t))}function x(n,r,t,u){return u>=0&&u<=15?g(a)(n,r,t):v(s(n,r),s(d(n),t))}function j(n){return o(n>=0&&n<=15?"79cc4519":"7a879d8a")}function y(n,r){for(var t=[],u=[],e=0;e<16;e++)t.push(r.substr(32*e,32));for(var o=16;o<68;o++)t.push(g(a)(b(g(a)(t[o-16],t[o-9],f(t[o-3],15))),f(t[o-13],7),t[o-6]));for(var i=0;i<64;i++)u.push(a(t[i],t[i+4]));for(var c=[],s=0;s<8;s++)c.push(n.substr(32*s,32));for(var v=c[0],d=c[1],y=c[2],S=c[3],w=c[4],m=c[5],A=c[6],O=c[7],P=void 0,I=void 0,_=void 0,M=void 0,k=0;k<64;k++)P=f(g(l)(f(v,12),w,f(j(k),k)),7),I=a(P,f(v,12)),_=g(l)(h(v,d,y,k),S,I,u[k]),M=g(l)(x(w,m,A,k),O,P,t[k]),S=y,y=f(d,9),d=v,v=_,O=A,A=f(m,19),m=w,w=p(M);return a([v,d,y,S,w,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"+u("",f)+u(t.toString(2),64)).toString(),a=(t+f+65)/512,s=o("7380166f4914b2b9172442d7da8a0600a96f30bc163138aae38dee4db0fb0e4e"),v=0;v<=a-1;v++){s=y(s,c.substr(512*v,512))}return e(s)}}});
window.sm3=function(n){function r(u){if(t[u])return t[u].exports;var o=t[u]={i:u,l:!1,exports:{}};return n[u].call(o.exports,o,o.exports,r),o.l=!0,o.exports}var t={};return r.m=n,r.c=t,r.d=function(n,t,u){r.o(n,t)||Object.defineProperty(n,t,{configurable:!1,enumerable:!0,get:u})},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 u(n,r){return n.length>=r?n:new Array(r-n.length+1).join("0")+n}function o(n){for(var r="",t=0;t<n.length/8;t++)r+=u(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+=u(parseInt(n.substr(2*t,2),16).toString(2),8);return r}function i(n){for(var r="",t=0,o=n.length;t<o;t++){var e=n.charCodeAt(t);e<=127?r+=u(e.toString(2),8):e<=2047?(r+=u((192|e>>>6).toString(2),8),r+=u((128|63&e).toString(2),8)):(r+=u((224|e>>>12).toString(2),8),r+=u((128|e>>>6&63).toString(2),8),r+=u((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 u=n||"",o=r||"",e=[],i=void 0,f=u.length-1;f>=0;f--)i=t(u[f],o[f],i),e[f]=i[0];return e.join("")}function a(n,r){return c(n,r,function(n,r){return[n===r?"0":"1"]})}function s(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 v(n,r){return c(n,r,function(n,r,t){var u=t?t[1]:"0";return n!==r?["0"===u?"1":"0",u]:[u,n]})}function l(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),u=0;u<r;u++)t[u]=arguments[u];return t.reduce(function(r,t){return n(r,t)})}}function p(n){return d(a)(n,f(n,9),f(n,17))}function b(n){return d(a)(n,f(n,15),f(n,23))}function h(n,r,t,u){return u>=0&&u<=15?d(a)(n,r,t):d(g)(s(n,r),s(n,t),s(r,t))}function S(n,r,t,u){return u>=0&&u<=15?d(a)(n,r,t):g(s(n,r),s(l(n),t))}function x(n){return e(n>=0&&n<=15?"79cc4519":"7a879d8a")}function j(n,r){for(var t=[],u=[],o=0;o<16;o++)t.push(r.substr(32*o,32));for(var e=16;e<68;e++)t.push(d(a)(b(d(a)(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++)u.push(a(t[i],t[i+4]));for(var c=[],s=0;s<8;s++)c.push(n.substr(32*s,32));for(var g=c[0],l=c[1],j=c[2],y=c[3],w=c[4],m=c[5],A=c[6],O=c[7],I=void 0,P=void 0,_=void 0,C=void 0,M=0;M<64;M++)I=f(d(v)(f(g,12),w,f(x(M),M)),7),P=a(I,f(g,12)),_=d(v)(h(g,l,j,M),y,P,u[M]),C=d(v)(S(w,m,A,M),O,I,t[M]),y=j,j=f(l,9),l=g,g=_,O=A,A=f(m,19),m=w,w=p(C);return a([g,l,j,y,w,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"+u("",f)+u(t.toString(2),64)).toString(),a=(t+f+65)/512,s=e("7380166f4914b2b9172442d7da8a0600a96f30bc163138aae38dee4db0fb0e4e"),g=0;g<=a-1;g++){s=j(s,c.substr(512*g,512))}return o(s)}}});
{
"name": "sm-crypto",
"version": "0.2.1",
"version": "0.2.2",
"description": "sm-crypto",

@@ -38,6 +38,6 @@ "main": "src/index.js",

"eslint-config-airbnb-base": "13.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-promise": "^3.8.0"
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-promise": "^3.8.0"
}
}

@@ -39,6 +39,21 @@ /**

let binary = ''
for (let i = 0, len = str.length; i < len; i++) {
const ch = str[i]
binary += leftPad(ch.codePointAt(0).toString(2), 8)
const point = str.charCodeAt(i)
if (point <= 0x007f) {
// 单字节,标量值:00000000 00000000 0zzzzzzz
binary += leftPad(point.toString(2), 8)
} else if (point <= 0x07ff) {
// 双字节,标量值:00000000 00000yyy yyzzzzzz
binary += leftPad((0xc0 | (point >>> 6)).toString(2), 8) // 110yyyyy(0xc0-0xdf)
binary += leftPad((0x80 | (point & 0x3f)).toString(2), 8) // 10zzzzzz(0x80-0xbf)
} else {
// 三字节:标量值:00000000 xxxxyyyy yyzzzzzz
binary += leftPad((0xe0 | (point >>> 12)).toString(2), 8) // 1110xxxx(0xe0-0xef)
binary += leftPad((0x80 | ((point >>> 6) & 0x3f)).toString(2), 8) // 10yyyyyy(0x80-0xbf)
binary += leftPad((0x80 | (point & 0x3f)).toString(2), 8) // 10zzzzzz(0x80-0xbf)
}
}
return binary

@@ -98,4 +113,4 @@ }

// a,b不等时,carry不变,结果与carry相反
// a,b相等时,结果等于原carry,新carry等于a
// a, b 不等时,carry 不变,结果与 carry 相反
// a, b 相等时,结果等于原 carry,新 carry 等于 a
if (a !== b) return [carry === '0' ? '1' : '0', carry]

@@ -220,3 +235,3 @@

// k是满足len + 1 + k = 448mod512的最小的非负整数
// k 是满足 len + 1 + k = 448mod512 的最小的非负整数
let k = len % 512

@@ -223,0 +238,0 @@

@@ -68,3 +68,3 @@ /* eslint-disable no-bitwise, no-mixed-operators, complexity */

if (point <= 0x007f) {
// 单子节,标量值:00000000 00000000 0zzzzzzz
// 单字节,标量值:00000000 00000000 0zzzzzzz
arr.push(point)

@@ -71,0 +71,0 @@ } else if (point <= 0x07ff) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc