@ray-js/wechat-helper
Advanced tools
Comparing version 0.0.15 to 0.0.16-beta-1
@@ -1,1 +0,1 @@ | ||
function t(t,e=2){let r=t;return"string"==typeof t&&(r=parseInt(t)),r.toString(16).padStart(e,"0")}function e(e){const r=[];return Array.prototype.map.call(new Uint8Array(e),(function(e){r.push(t(e))})),r}function r(t){return parseInt(t,16)}function n(t){const e=[];if("string"==typeof t)for(let r=0;r<t.length;r+=2){const n=parseInt(t.slice(r,r+2),16);e.push(String.fromCharCode(n))}else for(let r=0;r<t.length;r++){const n=parseInt(t[r],16);e.push(String.fromCharCode(n))}return e.join("")}function o(t){const e=[];if("string"==typeof t)for(let r=0;r<t.length;r+=2)e.push(parseInt(t.slice(r,r+2),16));else if("string"==typeof t[0])for(let r=0;r<t.length;r++)e.push(parseInt(t[r],16));return new Uint8Array(e)}function s(t){const e=255&t;let r=0;return e>=128?(r=e%128,r=-1*(128-r)):r=e,r}function l(t){const e=s(255&t);return[s(t>>8&255),e]}function u(t,e=!1){const r=t.length,n=new Uint8Array(e?4*r:r);let o=0;for(let s=0;s<r;s++){let l=t.charCodeAt(s);if(e&&55296<=l&&l<=56319){if(++s>=r)throw new Error("Malformed string, low surrogate expected at position "+s);l=(55296^l)<<10|65536|56320^t.charCodeAt(s)}else if(!e&&l>>>8)throw new Error("Wide characters are not allowed.");!e||l<=127?n[o++]=l:l<=2047?(n[o++]=192|l>>6,n[o++]=128|63&l):l<=65535?(n[o++]=224|l>>12,n[o++]=128|l>>6&63,n[o++]=128|63&l):(n[o++]=240|l>>18,n[o++]=128|l>>12&63,n[o++]=128|l>>6&63,n[o++]=128|63&l)}return n.subarray(0,o)}function i(t){return u(t,!0)}function c(t,e=!1){const r=t.length,n=new Array(r);let o=0;for(let s=0;s<r;s++){const l=t[s];if(!e||l<128)n[o++]=l;else if(l>=192&&l<224&&s+1<r)n[o++]=(31&l)<<6|63&t[++s];else if(l>=224&&l<240&&s+2<r)n[o++]=(15&l)<<12|(63&t[++s])<<6|63&t[++s];else{if(!(l>=240&&l<248&&s+3<r))throw new Error("Malformed UTF8 character at byte offset "+s);{let e=(7&l)<<18|(63&t[++s])<<12|(63&t[++s])<<6|63&t[++s];e<=65535?n[o++]=e:(e^=65536,n[o++]=55296|e>>10,n[o++]=56320|1023&e)}}}let s="";const l=16384;for(let t=0;t<o;t+=l)s+=String.fromCharCode(...n.slice(t,t+l<=o?t+l:o));return s}const a=(t,e=!1)=>{if(!t)return"";return Object.keys(t).reduce(((r,n)=>{const o=t[n];return void 0!==o&&r.push(`${n}=${e?encodeURIComponent(o):o}`),r}),[]).join("&")},f=t=>{const e=wx.getSystemInfoSync().SDKVersion;return h(t,e)},h=(t,e,r=!0)=>{const n=t.split("."),o=e.split("."),s=Math.max(o.length,n.length);for(;o.length<s;)o.splice(0,0,"0");for(;n.length<s;)n.splice(0,0,"0");for(let t=0;t<s;t++){const e=parseInt(n[t]),r=parseInt(o[t]);if(e>r)return!0;if(e===r)break;return!1}return r},p=t=>t.replace(/^\S/,(function(t){return t.toUpperCase()}));function g(t){return"object"!=typeof t?t:Array.isArray(t)?t.map((t=>g(t))):Object.keys(t).reduce(((e,r)=>{const n=r.split("_").map(((t,e)=>e>0?p(t):t)).join("");let o=t[r];return Array.isArray(o)?o=o.map((t=>g(t))):"object"==typeof o&&(o=g(o)),e[n]=o,e}),{})}const w=new Uint32Array(256);for(let t=0;t<256;t++){let e=t;for(let t=0;t<8;t++)e=1&e?e>>>1^3988292384:e>>>1;w[t]=e}function d(t){let e=-1;for(let r=0,n=t.length;r<n;r++)e=e>>>8^w[255&(e^t[r])];return-1^e}function y(t){let e=65535;let r,n;for(r=0;r<t.length;r++)for(e^=255&t[r],n=0;n<8;n++)0!=(1&e)?(e>>=1,e^=40961):e>>=1;return e}const C={initial_value:0,table:function(t){const e=[];for(let r=0;r<256;++r){let n=r;for(let e=0;e<8;++e)n=0!=(128&n)?(n<<1^t)%256:(n<<1)%256;e[r]=n}return e}(7)},m=t=>{let e=C.initial_value;for(let r=0;r<t.length;r++)e=C.table[(e^t[r])%256];return e};function A(t,e){return!!((t&Math.pow(2,e))>>e)}function S(t){if(t.length>6)throw new Error("The number of bytes exceeds 6");const e=new DataView(t.buffer);switch(t.length){case 1:return e.getInt8(0);case 2:return e.getInt16(0);case 4:return e.getInt32(0);default:{let e=I(t);const r=Math.pow(2,8*t.length)/2;return e>=r&&(e%=r,e=-1*(r-e)),e}}}function I(t){const e=new DataView(t.buffer);switch(t.length){case 1:return e.getUint8(0);case 2:return e.getUint16(0);case 3:return t.reduce(((t,e)=>t<<8|e),0);case 4:return e.getUint32(0);default:return parseInt(b(t),16)}}function U(t){return t.reduceRight(((t,e)=>{const r=e.toString(2).padStart(8,"0").split("").map((t=>Number(t))).reverse();return t.concat(r)}),[])}function b(t){return t.length<=4?I(t).toString(16).padStart(2*t.length,"0").toUpperCase():t.reduce(((t,e)=>(t.push(e.toString(16).padStart(2,"0")),t)),[]).join("").toUpperCase()}function j(t){return t.length%2!=0?(console.error("Illegal Format UTF16 Code!"),""):t.reduce(((t,e)=>(t.push(String.fromCharCode(e)),t)),[]).join("")}function M(t){const e=[];let r=0;for(;r<t.length;){const n=t[r];n<128?(e.push(String.fromCharCode(n)),r++):n>191&&n<224?(e.push(String.fromCharCode((31&n)<<6|63&t[r+1])),r+=2):(e.push(String.fromCharCode((15&n)<<12|(63&t[r+1])<<6|63&t[r+2])),r+=3)}return e.join("")}function v(t){const e=[],r=t.length;for(let n=0;n<r;n++){const r=t.charCodeAt(n);r>=65536&&r<=1114111?(e.push(r>>18&7|240),e.push(r>>12&63|128),e.push(r>>6&63|128),e.push(63&r|128)):r>=2048&&r<=65535?(e.push(r>>12&15|224),e.push(r>>6&63|128),e.push(63&r|128)):r>=128&&r<=2047?(e.push(r>>6&31|192),e.push(63&r|128)):e.push(255&r)}return new Uint8Array(e)}function x(t){const e=[],r=t.length;for(let n=0;n<r;n++){const r=t[n].toString(2),o=r.match(/^1+?(?=0)/);if(o&&8==r.length){const s=o[0].length;let l=r.slice(7-s);for(let e=1;e<s;e++)l+=t[e+n].toString(2).slice(2);e.push(String.fromCharCode(parseInt(l,2))),n+=s-1}else e.push(String.fromCharCode(t[n]))}return e.join("")}const D=t=>{const e=new Uint8Array(t);for(let r=0;r<t;r++)e[r]=Math.floor(256*Math.random());return e},E=t=>{const e=[];do{let r=t%128;(t=parseInt(""+t/128))>0&&(r|=128),e.push(r)}while(t>0);return new Uint8Array(e)},V=(t,e=0)=>{let r=0,n=e;for(;n<4&&n<t.length;n++){const o=t[n];if(r|=(127&o)<<7*(n-e),0==(o>>7&1))break}return{num:r,end:n-e<4?n+1:n}},k=(t,e)=>{const r=new Uint32Array([t]),n=new Uint8Array(r.buffer);return n.reverse(),e?n.slice(4-e):n},F=(t,e)=>{const r=new Int32Array([t]),n=new Int8Array(r.buffer);return n.reverse(),e?new Uint8Array(n.slice(4-e)):new Uint8Array(n)},T=t=>{if(t.length%2!=0)throw new Error("hex length error");const e=t.length/2,r=new Uint8Array(e);for(let n=0;n<e;n++)r[n]=parseInt(t.slice(2*n,2*n+2),16);return r},_=t=>{const e=new DataView(t.buffer),r=[];for(let n=0;n<t.length;n+=4)r.push(e.getInt32(n));return r},O=t=>{const e=new Uint8Array(4*t.length),r=new DataView(e.buffer);for(let e=0;e<t.length;e++)r.setInt32(4*e,t[e]);return e};const R={encrypt:function(t,e){const r=_(t),n=_(e),o=r.length-1;let s,l,u=r[o],i=r[0],c=Math.floor(6+52/(o+1)),a=0;for(;c-- >0;){a=a+2654435769&4294967295,l=a>>>2&3;let t=0;for(;t<o;t++)i=r[t+1],s=(u>>>5^i<<2)+(i>>>3^u<<4)^(a^i)+(n[3&t^l]^u),u=r[t]=r[t]+s&4294967295;i=r[0],s=(u>>>5^i<<2)+(i>>>3^u<<4)^(a^i)+(n[3&t^l]^u),u=r[o]=r[o]+s&4294967295}return O(r)},decrypt:function(t,e){const r=_(t),n=_(e),o=r.length-1;let s=r[o-1],l=r[0];const u=2654435769;let i,c,a=Math.floor(6+52/(o+1))*u&4294967295;for(;0!==a;){c=a>>>2&3;let t=o;for(;t>0;t--)s=r[t-1],i=(s>>>5^l<<2)+(l>>>3^s<<4)^(a^l)+(n[3&t^c]^s),l=r[t]=r[t]-i&4294967295;s=r[o],i=(s>>>5^l<<2)+(l>>>3^s<<4)^(a^l)+(n[3&t^c]^s),l=r[0]=r[0]-i&4294967295,a=a-u&4294967295}return O(r)}};export{y as CRC16,d as CRC32,m as CRC8,e as ab2hex,A as bitToBoolean,c as bytes2string,U as bytesToBits,j as bytesToCharts,b as bytesToHex,S as bytesToInt,V as bytesToIntBy128,x as bytesToString,I as bytesToUint,M as bytesToUtf8,h as checkVersion,f as checkWxVersion,t as dec2hex,p as firstUpperCase,a as formatQuery,o as hex2ab,r as hex2dec,n as hex2string,T as hexToBytes,l as int2TwoBytes,s as intToByte,F as intToBytes,g as keyToHump,D as randomBytes,u as string2bytes,v as stringToBytes,k as uintToBytes,E as uintToBytesBy128,i as utf8ToBytes,R as xxtea}; | ||
function t(t,e=2){let r=t;return"string"==typeof t&&(r=parseInt(t)),r.toString(16).padStart(e,"0")}function e(e){const r=[];return Array.prototype.map.call(new Uint8Array(e),(function(e){r.push(t(e))})),r}function r(t){return parseInt(t,16)}function n(t){const e=[];if("string"==typeof t)for(let r=0;r<t.length;r+=2){const n=parseInt(t.slice(r,r+2),16);e.push(String.fromCharCode(n))}else for(let r=0;r<t.length;r++){const n=parseInt(t[r],16);e.push(String.fromCharCode(n))}return e.join("")}function o(t){const e=[];if("string"==typeof t)for(let r=0;r<t.length;r+=2)e.push(parseInt(t.slice(r,r+2),16));else if("string"==typeof t[0])for(let r=0;r<t.length;r++)e.push(parseInt(t[r],16));return new Uint8Array(e)}function s(t){const e=255&t;let r=0;return e>=128?(r=e%128,r=-1*(128-r)):r=e,r}function u(t){const e=s(255&t);return[s(t>>8&255),e]}function l(t,e=!1){const r=t.length,n=new Uint8Array(e?4*r:r);let o=0;for(let s=0;s<r;s++){let u=t.charCodeAt(s);if(e&&55296<=u&&u<=56319){if(++s>=r)throw new Error("Malformed string, low surrogate expected at position "+s);u=(55296^u)<<10|65536|56320^t.charCodeAt(s)}else if(!e&&u>>>8)throw new Error("Wide characters are not allowed.");!e||u<=127?n[o++]=u:u<=2047?(n[o++]=192|u>>6,n[o++]=128|63&u):u<=65535?(n[o++]=224|u>>12,n[o++]=128|u>>6&63,n[o++]=128|63&u):(n[o++]=240|u>>18,n[o++]=128|u>>12&63,n[o++]=128|u>>6&63,n[o++]=128|63&u)}return n.subarray(0,o)}function i(t){return l(t,!0)}function c(t,e=!1){const r=t.length,n=new Array(r);let o=0;for(let s=0;s<r;s++){const u=t[s];if(!e||u<128)n[o++]=u;else if(u>=192&&u<224&&s+1<r)n[o++]=(31&u)<<6|63&t[++s];else if(u>=224&&u<240&&s+2<r)n[o++]=(15&u)<<12|(63&t[++s])<<6|63&t[++s];else{if(!(u>=240&&u<248&&s+3<r))throw new Error("Malformed UTF8 character at byte offset "+s);{let e=(7&u)<<18|(63&t[++s])<<12|(63&t[++s])<<6|63&t[++s];e<=65535?n[o++]=e:(e^=65536,n[o++]=55296|e>>10,n[o++]=56320|1023&e)}}}let s="";const u=16384;for(let t=0;t<o;t+=u)s+=String.fromCharCode(...n.slice(t,t+u<=o?t+u:o));return s}const f=(t,e=!1)=>{if(!t)return"";return Object.keys(t).reduce(((r,n)=>{const o=t[n];return void 0!==o&&r.push(`${n}=${e?encodeURIComponent(o):o}`),r}),[]).join("&")},a=t=>{const e=wx.getSystemInfoSync().SDKVersion;return h(t,e)},h=(t,e,r=!0)=>{const n=t.split("."),o=e.split("."),s=Math.max(o.length,n.length);for(;o.length<s;)o.splice(0,0,"0");for(;n.length<s;)n.splice(0,0,"0");for(let t=0;t<s;t++){const e=parseInt(n[t]),r=parseInt(o[t]);if(e>r)return!0;if(e===r)break;return!1}return r},p=t=>t.replace(/^\S/,(function(t){return t.toUpperCase()}));function g(t){return"object"!=typeof t?t:Array.isArray(t)?t.map((t=>g(t))):Object.keys(t).reduce(((e,r)=>{const n=r.split("_").map(((t,e)=>e>0?p(t):t)).join("");let o=t[r];return Array.isArray(o)?o=o.map((t=>g(t))):"object"==typeof o&&(o=g(o)),e[n]=o,e}),{})}const w=new Uint32Array(256);for(let t=0;t<256;t++){let e=t;for(let t=0;t<8;t++)e=1&e?e>>>1^3988292384:e>>>1;w[t]=e}function d(t){let e=-1;for(let r=0,n=t.length;r<n;r++)e=e>>>8^w[255&(e^t[r])];return-1^e}function y(t){let e=65535;let r,n;for(r=0;r<t.length;r++)for(e^=255&t[r],n=0;n<8;n++)0!=(1&e)?(e>>=1,e^=40961):e>>=1;return e}const C={initial_value:0,table:function(t){const e=[];for(let r=0;r<256;++r){let n=r;for(let e=0;e<8;++e)n=0!=(128&n)?(n<<1^t)%256:(n<<1)%256;e[r]=n}return e}(7)},m=t=>{let e=C.initial_value;for(let r=0;r<t.length;r++)e=C.table[(e^t[r])%256];return e};function A(t,e){return!!((t&Math.pow(2,e))>>e)}function S(t){if(t.length>6)throw new Error("The number of bytes exceeds 6");const e=new DataView(t.buffer);switch(t.length){case 1:return e.getInt8(0);case 2:return e.getInt16(0);case 4:return e.getInt32(0);default:{let e=I(t);const r=Math.pow(2,8*t.length)/2;return e>=r&&(e%=r,e=-1*(r-e)),e}}}function I(t){const e=new DataView(t.buffer);switch(t.length){case 1:return e.getUint8(0);case 2:return e.getUint16(0);case 3:return t.reduce(((t,e)=>t<<8|e),0);case 4:return e.getUint32(0);default:return parseInt(b(t),16)}}function U(t){return t.reduceRight(((t,e)=>{const r=e.toString(2).padStart(8,"0").split("").map((t=>Number(t))).reverse();return t.concat(r)}),[])}function b(t){return t.length<=4?I(t).toString(16).padStart(2*t.length,"0").toUpperCase():t.reduce(((t,e)=>(t.push(e.toString(16).padStart(2,"0")),t)),[]).join("").toUpperCase()}function j(t){return t.length%2!=0?(console.error("Illegal Format UTF16 Code!"),""):t.reduce(((t,e)=>(t.push(String.fromCharCode(e)),t)),[]).join("")}function M(t){const e=[];let r=0;for(;r<t.length;){const n=t[r];n<128?(e.push(String.fromCharCode(n)),r++):n>191&&n<224?(e.push(String.fromCharCode((31&n)<<6|63&t[r+1])),r+=2):(e.push(String.fromCharCode((15&n)<<12|(63&t[r+1])<<6|63&t[r+2])),r+=3)}return e.join("")}function v(t){const e=[],r=t.length;for(let n=0;n<r;n++){const r=t.charCodeAt(n);r>=65536&&r<=1114111?(e.push(r>>18&7|240),e.push(r>>12&63|128),e.push(r>>6&63|128),e.push(63&r|128)):r>=2048&&r<=65535?(e.push(r>>12&15|224),e.push(r>>6&63|128),e.push(63&r|128)):r>=128&&r<=2047?(e.push(r>>6&31|192),e.push(63&r|128)):e.push(255&r)}return new Uint8Array(e)}function x(t){const e=[],r=t.length;for(let n=0;n<r;n++){const r=t[n].toString(2),o=r.match(/^1+?(?=0)/);if(o&&8==r.length){const s=o[0].length;let u=r.slice(7-s);for(let e=1;e<s;e++)u+=t[e+n].toString(2).slice(2);e.push(String.fromCharCode(parseInt(u,2))),n+=s-1}else e.push(String.fromCharCode(t[n]))}return e.join("")}const D=t=>{const e=new Uint8Array(t);for(let r=0;r<t;r++)e[r]=Math.floor(256*Math.random());return e},E=t=>{const e=[];do{let r=t%128;(t=parseInt(""+t/128))>0&&(r|=128),e.push(r)}while(t>0);return new Uint8Array(e)},T=(t,e=0)=>{let r=0,n=e;for(;n<4&&n<t.length;n++){const o=t[n];if(r|=(127&o)<<7*(n-e),0==(o>>7&1))break}return{num:r,end:n-e<4?n+1:n}},V=(t,e)=>{const r=new Uint32Array([t]),n=new Uint8Array(r.buffer);return n.reverse(),e?n.slice(4-e):n},k=(t,e)=>{const r=new Int32Array([t]),n=new Int8Array(r.buffer);return n.reverse(),e?new Uint8Array(n.slice(4-e)):new Uint8Array(n)},F=t=>{if(t.length%2!=0)throw new Error("hex length error");const e=t.length/2,r=new Uint8Array(e);for(let n=0;n<e;n++)r[n]=parseInt(t.slice(2*n,2*n+2),16);return r},_=t=>{const e=new DataView(t.buffer),r=[];for(let n=0;n<t.length;n+=4)r.push(e.getInt32(n));return r},O=t=>{const e=new Uint8Array(4*t.length),r=new DataView(e.buffer);for(let e=0;e<t.length;e++)r.setInt32(4*e,t[e]);return e};const R={encrypt:function(t,e){const r=_(t),n=_(e),o=r.length-1;let s,u,l=r[o],i=r[0],c=Math.floor(6+52/(o+1)),f=0;for(;c-- >0;){f=f+2654435769&4294967295,u=f>>>2&3;let t=0;for(;t<o;t++)i=r[t+1],s=(l>>>5^i<<2)+(i>>>3^l<<4)^(f^i)+(n[3&t^u]^l),l=r[t]=r[t]+s&4294967295;i=r[0],s=(l>>>5^i<<2)+(i>>>3^l<<4)^(f^i)+(n[3&t^u]^l),l=r[o]=r[o]+s&4294967295}return O(r)},decrypt:function(t,e){const r=_(t),n=_(e),o=r.length-1;let s=r[o-1],u=r[0];const l=2654435769;let i,c,f=Math.floor(6+52/(o+1))*l&4294967295;for(;0!==f;){c=f>>>2&3;let t=o;for(;t>0;t--)s=r[t-1],i=(s>>>5^u<<2)+(u>>>3^s<<4)^(f^u)+(n[3&t^c]^s),u=r[t]=r[t]-i&4294967295;s=r[o],i=(s>>>5^u<<2)+(u>>>3^s<<4)^(f^u)+(n[3&t^c]^s),u=r[0]=r[0]-i&4294967295,f=f-l&4294967295}return O(r)}},$={},K=()=>"undefined"!=typeof globalThis?globalThis:$;function N(t,e){const r=K();return r[t]?r[t][e]:null}function W(t){const e=K();return e[t]?e[t]:null}function q(t,e,r){const n=K();n[t]||(n[t]={}),n[t][e]=r}function z(t){const e=K();e[t]&&(e[t]={})}export{y as CRC16,d as CRC32,m as CRC8,e as ab2hex,A as bitToBoolean,c as bytes2string,U as bytesToBits,j as bytesToCharts,b as bytesToHex,S as bytesToInt,T as bytesToIntBy128,x as bytesToString,I as bytesToUint,M as bytesToUtf8,h as checkVersion,a as checkWxVersion,z as clearCache,t as dec2hex,p as firstUpperCase,f as formatQuery,N as getCache,W as getCacheSpace,o as hex2ab,r as hex2dec,n as hex2string,F as hexToBytes,u as int2TwoBytes,s as intToByte,k as intToBytes,g as keyToHump,D as randomBytes,q as setCache,l as string2bytes,v as stringToBytes,V as uintToBytes,E as uintToBytesBy128,i as utf8ToBytes,R as xxtea}; |
@@ -1,1 +0,1 @@ | ||
"use strict";function t(t,e=2){let r=t;return"string"==typeof t&&(r=parseInt(t)),r.toString(16).padStart(e,"0")}function e(t){const e=255&t;let r=0;return e>=128?(r=e%128,r=-1*(128-r)):r=e,r}function r(t,e=!1){const r=t.length,n=new Uint8Array(e?4*r:r);let o=0;for(let s=0;s<r;s++){let i=t.charCodeAt(s);if(e&&55296<=i&&i<=56319){if(++s>=r)throw new Error("Malformed string, low surrogate expected at position "+s);i=(55296^i)<<10|65536|56320^t.charCodeAt(s)}else if(!e&&i>>>8)throw new Error("Wide characters are not allowed.");!e||i<=127?n[o++]=i:i<=2047?(n[o++]=192|i>>6,n[o++]=128|63&i):i<=65535?(n[o++]=224|i>>12,n[o++]=128|i>>6&63,n[o++]=128|63&i):(n[o++]=240|i>>18,n[o++]=128|i>>12&63,n[o++]=128|i>>6&63,n[o++]=128|63&i)}return n.subarray(0,o)}Object.defineProperty(exports,"__esModule",{value:!0});const n=(t,e,r=!0)=>{const n=t.split("."),o=e.split("."),s=Math.max(o.length,n.length);for(;o.length<s;)o.splice(0,0,"0");for(;n.length<s;)n.splice(0,0,"0");for(let t=0;t<s;t++){const e=parseInt(n[t]),r=parseInt(o[t]);if(e>r)return!0;if(e===r)break;return!1}return r},o=t=>t.replace(/^\S/,(function(t){return t.toUpperCase()}));const s=new Uint32Array(256);for(let t=0;t<256;t++){let e=t;for(let t=0;t<8;t++)e=1&e?e>>>1^3988292384:e>>>1;s[t]=e}const i={initial_value:0,table:function(t){const e=[];for(let r=0;r<256;++r){let n=r;for(let e=0;e<8;++e)n=0!=(128&n)?(n<<1^t)%256:(n<<1)%256;e[r]=n}return e}(7)};function u(t){const e=new DataView(t.buffer);switch(t.length){case 1:return e.getUint8(0);case 2:return e.getUint16(0);case 3:return t.reduce(((t,e)=>t<<8|e),0);case 4:return e.getUint32(0);default:return parseInt(c(t),16)}}function c(t){return t.length<=4?u(t).toString(16).padStart(2*t.length,"0").toUpperCase():t.reduce(((t,e)=>(t.push(e.toString(16).padStart(2,"0")),t)),[]).join("").toUpperCase()}const l=t=>{const e=new DataView(t.buffer),r=[];for(let n=0;n<t.length;n+=4)r.push(e.getInt32(n));return r},a=t=>{const e=new Uint8Array(4*t.length),r=new DataView(e.buffer);for(let e=0;e<t.length;e++)r.setInt32(4*e,t[e]);return e};const f={encrypt:function(t,e){const r=l(t),n=l(e),o=r.length-1;let s,i,u=r[o],c=r[0],f=Math.floor(6+52/(o+1)),p=0;for(;f-- >0;){p=p+2654435769&4294967295,i=p>>>2&3;let t=0;for(;t<o;t++)c=r[t+1],s=(u>>>5^c<<2)+(c>>>3^u<<4)^(p^c)+(n[3&t^i]^u),u=r[t]=r[t]+s&4294967295;c=r[0],s=(u>>>5^c<<2)+(c>>>3^u<<4)^(p^c)+(n[3&t^i]^u),u=r[o]=r[o]+s&4294967295}return a(r)},decrypt:function(t,e){const r=l(t),n=l(e),o=r.length-1;let s=r[o-1],i=r[0];const u=2654435769;let c,f,p=Math.floor(6+52/(o+1))*u&4294967295;for(;0!==p;){f=p>>>2&3;let t=o;for(;t>0;t--)s=r[t-1],c=(s>>>5^i<<2)+(i>>>3^s<<4)^(p^i)+(n[3&t^f]^s),i=r[t]=r[t]-c&4294967295;s=r[o],c=(s>>>5^i<<2)+(i>>>3^s<<4)^(p^i)+(n[3&t^f]^s),i=r[0]=r[0]-c&4294967295,p=p-u&4294967295}return a(r)}};exports.CRC16=function(t){let e,r,n=65535;for(e=0;e<t.length;e++)for(n^=255&t[e],r=0;r<8;r++)0!=(1&n)?(n>>=1,n^=40961):n>>=1;return n},exports.CRC32=function(t){let e=-1;for(let r=0,n=t.length;r<n;r++)e=e>>>8^s[255&(e^t[r])];return-1^e},exports.CRC8=t=>{let e=i.initial_value;for(let r=0;r<t.length;r++)e=i.table[(e^t[r])%256];return e},exports.ab2hex=function(e){const r=[];return Array.prototype.map.call(new Uint8Array(e),(function(e){r.push(t(e))})),r},exports.bitToBoolean=function(t,e){return!!((t&Math.pow(2,e))>>e)},exports.bytes2string=function(t,e=!1){const r=t.length,n=new Array(r);let o=0;for(let s=0;s<r;s++){const i=t[s];if(!e||i<128)n[o++]=i;else if(i>=192&&i<224&&s+1<r)n[o++]=(31&i)<<6|63&t[++s];else if(i>=224&&i<240&&s+2<r)n[o++]=(15&i)<<12|(63&t[++s])<<6|63&t[++s];else{if(!(i>=240&&i<248&&s+3<r))throw new Error("Malformed UTF8 character at byte offset "+s);{let e=(7&i)<<18|(63&t[++s])<<12|(63&t[++s])<<6|63&t[++s];e<=65535?n[o++]=e:(e^=65536,n[o++]=55296|e>>10,n[o++]=56320|1023&e)}}}let s="";const i=16384;for(let t=0;t<o;t+=i)s+=String.fromCharCode(...n.slice(t,t+i<=o?t+i:o));return s},exports.bytesToBits=function(t){return t.reduceRight(((t,e)=>{const r=e.toString(2).padStart(8,"0").split("").map((t=>Number(t))).reverse();return t.concat(r)}),[])},exports.bytesToCharts=function(t){return t.length%2!=0?(console.error("Illegal Format UTF16 Code!"),""):t.reduce(((t,e)=>(t.push(String.fromCharCode(e)),t)),[]).join("")},exports.bytesToHex=c,exports.bytesToInt=function(t){if(t.length>6)throw new Error("The number of bytes exceeds 6");const e=new DataView(t.buffer);switch(t.length){case 1:return e.getInt8(0);case 2:return e.getInt16(0);case 4:return e.getInt32(0);default:{let e=u(t);const r=Math.pow(2,8*t.length)/2;return e>=r&&(e%=r,e=-1*(r-e)),e}}},exports.bytesToIntBy128=(t,e=0)=>{let r=0,n=e;for(;n<4&&n<t.length;n++){const o=t[n];if(r|=(127&o)<<7*(n-e),0==(o>>7&1))break}return{num:r,end:n-e<4?n+1:n}},exports.bytesToString=function(t){const e=[],r=t.length;for(let n=0;n<r;n++){const r=t[n].toString(2),o=r.match(/^1+?(?=0)/);if(o&&8==r.length){const s=o[0].length;let i=r.slice(7-s);for(let e=1;e<s;e++)i+=t[e+n].toString(2).slice(2);e.push(String.fromCharCode(parseInt(i,2))),n+=s-1}else e.push(String.fromCharCode(t[n]))}return e.join("")},exports.bytesToUint=u,exports.bytesToUtf8=function(t){const e=[];let r=0;for(;r<t.length;){const n=t[r];n<128?(e.push(String.fromCharCode(n)),r++):n>191&&n<224?(e.push(String.fromCharCode((31&n)<<6|63&t[r+1])),r+=2):(e.push(String.fromCharCode((15&n)<<12|(63&t[r+1])<<6|63&t[r+2])),r+=3)}return e.join("")},exports.checkVersion=n,exports.checkWxVersion=t=>{const e=wx.getSystemInfoSync().SDKVersion;return n(t,e)},exports.dec2hex=t,exports.firstUpperCase=o,exports.formatQuery=(t,e=!1)=>{if(!t)return"";return Object.keys(t).reduce(((r,n)=>{const o=t[n];return void 0!==o&&r.push(`${n}=${e?encodeURIComponent(o):o}`),r}),[]).join("&")},exports.hex2ab=function(t){const e=[];if("string"==typeof t)for(let r=0;r<t.length;r+=2)e.push(parseInt(t.slice(r,r+2),16));else if("string"==typeof t[0])for(let r=0;r<t.length;r++)e.push(parseInt(t[r],16));return new Uint8Array(e)},exports.hex2dec=function(t){return parseInt(t,16)},exports.hex2string=function(t){const e=[];if("string"==typeof t)for(let r=0;r<t.length;r+=2){const n=parseInt(t.slice(r,r+2),16);e.push(String.fromCharCode(n))}else for(let r=0;r<t.length;r++){const n=parseInt(t[r],16);e.push(String.fromCharCode(n))}return e.join("")},exports.hexToBytes=t=>{if(t.length%2!=0)throw new Error("hex length error");const e=t.length/2,r=new Uint8Array(e);for(let n=0;n<e;n++)r[n]=parseInt(t.slice(2*n,2*n+2),16);return r},exports.int2TwoBytes=function(t){const r=e(255&t);return[e(t>>8&255),r]},exports.intToByte=e,exports.intToBytes=(t,e)=>{const r=new Int32Array([t]),n=new Int8Array(r.buffer);return n.reverse(),e?new Uint8Array(n.slice(4-e)):new Uint8Array(n)},exports.keyToHump=function t(e){return"object"!=typeof e?e:Array.isArray(e)?e.map((e=>t(e))):Object.keys(e).reduce(((r,n)=>{const s=n.split("_").map(((t,e)=>e>0?o(t):t)).join("");let i=e[n];return Array.isArray(i)?i=i.map((e=>t(e))):"object"==typeof i&&(i=t(i)),r[s]=i,r}),{})},exports.randomBytes=t=>{const e=new Uint8Array(t);for(let r=0;r<t;r++)e[r]=Math.floor(256*Math.random());return e},exports.string2bytes=r,exports.stringToBytes=function(t){const e=[],r=t.length;for(let n=0;n<r;n++){const r=t.charCodeAt(n);r>=65536&&r<=1114111?(e.push(r>>18&7|240),e.push(r>>12&63|128),e.push(r>>6&63|128),e.push(63&r|128)):r>=2048&&r<=65535?(e.push(r>>12&15|224),e.push(r>>6&63|128),e.push(63&r|128)):r>=128&&r<=2047?(e.push(r>>6&31|192),e.push(63&r|128)):e.push(255&r)}return new Uint8Array(e)},exports.uintToBytes=(t,e)=>{const r=new Uint32Array([t]),n=new Uint8Array(r.buffer);return n.reverse(),e?n.slice(4-e):n},exports.uintToBytesBy128=t=>{const e=[];do{let r=t%128;(t=parseInt(""+t/128))>0&&(r|=128),e.push(r)}while(t>0);return new Uint8Array(e)},exports.utf8ToBytes=function(t){return r(t,!0)},exports.xxtea=f; | ||
"use strict";function t(t,e=2){let r=t;return"string"==typeof t&&(r=parseInt(t)),r.toString(16).padStart(e,"0")}function e(t){const e=255&t;let r=0;return e>=128?(r=e%128,r=-1*(128-r)):r=e,r}function r(t,e=!1){const r=t.length,n=new Uint8Array(e?4*r:r);let o=0;for(let s=0;s<r;s++){let i=t.charCodeAt(s);if(e&&55296<=i&&i<=56319){if(++s>=r)throw new Error("Malformed string, low surrogate expected at position "+s);i=(55296^i)<<10|65536|56320^t.charCodeAt(s)}else if(!e&&i>>>8)throw new Error("Wide characters are not allowed.");!e||i<=127?n[o++]=i:i<=2047?(n[o++]=192|i>>6,n[o++]=128|63&i):i<=65535?(n[o++]=224|i>>12,n[o++]=128|i>>6&63,n[o++]=128|63&i):(n[o++]=240|i>>18,n[o++]=128|i>>12&63,n[o++]=128|i>>6&63,n[o++]=128|63&i)}return n.subarray(0,o)}Object.defineProperty(exports,"__esModule",{value:!0});const n=(t,e,r=!0)=>{const n=t.split("."),o=e.split("."),s=Math.max(o.length,n.length);for(;o.length<s;)o.splice(0,0,"0");for(;n.length<s;)n.splice(0,0,"0");for(let t=0;t<s;t++){const e=parseInt(n[t]),r=parseInt(o[t]);if(e>r)return!0;if(e===r)break;return!1}return r},o=t=>t.replace(/^\S/,(function(t){return t.toUpperCase()}));const s=new Uint32Array(256);for(let t=0;t<256;t++){let e=t;for(let t=0;t<8;t++)e=1&e?e>>>1^3988292384:e>>>1;s[t]=e}const i={initial_value:0,table:function(t){const e=[];for(let r=0;r<256;++r){let n=r;for(let e=0;e<8;++e)n=0!=(128&n)?(n<<1^t)%256:(n<<1)%256;e[r]=n}return e}(7)};function c(t){const e=new DataView(t.buffer);switch(t.length){case 1:return e.getUint8(0);case 2:return e.getUint16(0);case 3:return t.reduce(((t,e)=>t<<8|e),0);case 4:return e.getUint32(0);default:return parseInt(u(t),16)}}function u(t){return t.length<=4?c(t).toString(16).padStart(2*t.length,"0").toUpperCase():t.reduce(((t,e)=>(t.push(e.toString(16).padStart(2,"0")),t)),[]).join("").toUpperCase()}const l=t=>{const e=new DataView(t.buffer),r=[];for(let n=0;n<t.length;n+=4)r.push(e.getInt32(n));return r},a=t=>{const e=new Uint8Array(4*t.length),r=new DataView(e.buffer);for(let e=0;e<t.length;e++)r.setInt32(4*e,t[e]);return e};const f={encrypt:function(t,e){const r=l(t),n=l(e),o=r.length-1;let s,i,c=r[o],u=r[0],f=Math.floor(6+52/(o+1)),p=0;for(;f-- >0;){p=p+2654435769&4294967295,i=p>>>2&3;let t=0;for(;t<o;t++)u=r[t+1],s=(c>>>5^u<<2)+(u>>>3^c<<4)^(p^u)+(n[3&t^i]^c),c=r[t]=r[t]+s&4294967295;u=r[0],s=(c>>>5^u<<2)+(u>>>3^c<<4)^(p^u)+(n[3&t^i]^c),c=r[o]=r[o]+s&4294967295}return a(r)},decrypt:function(t,e){const r=l(t),n=l(e),o=r.length-1;let s=r[o-1],i=r[0];const c=2654435769;let u,f,p=Math.floor(6+52/(o+1))*c&4294967295;for(;0!==p;){f=p>>>2&3;let t=o;for(;t>0;t--)s=r[t-1],u=(s>>>5^i<<2)+(i>>>3^s<<4)^(p^i)+(n[3&t^f]^s),i=r[t]=r[t]-u&4294967295;s=r[o],u=(s>>>5^i<<2)+(i>>>3^s<<4)^(p^i)+(n[3&t^f]^s),i=r[0]=r[0]-u&4294967295,p=p-c&4294967295}return a(r)}},p={},h=()=>"undefined"!=typeof globalThis?globalThis:p;exports.CRC16=function(t){let e,r,n=65535;for(e=0;e<t.length;e++)for(n^=255&t[e],r=0;r<8;r++)0!=(1&n)?(n>>=1,n^=40961):n>>=1;return n},exports.CRC32=function(t){let e=-1;for(let r=0,n=t.length;r<n;r++)e=e>>>8^s[255&(e^t[r])];return-1^e},exports.CRC8=t=>{let e=i.initial_value;for(let r=0;r<t.length;r++)e=i.table[(e^t[r])%256];return e},exports.ab2hex=function(e){const r=[];return Array.prototype.map.call(new Uint8Array(e),(function(e){r.push(t(e))})),r},exports.bitToBoolean=function(t,e){return!!((t&Math.pow(2,e))>>e)},exports.bytes2string=function(t,e=!1){const r=t.length,n=new Array(r);let o=0;for(let s=0;s<r;s++){const i=t[s];if(!e||i<128)n[o++]=i;else if(i>=192&&i<224&&s+1<r)n[o++]=(31&i)<<6|63&t[++s];else if(i>=224&&i<240&&s+2<r)n[o++]=(15&i)<<12|(63&t[++s])<<6|63&t[++s];else{if(!(i>=240&&i<248&&s+3<r))throw new Error("Malformed UTF8 character at byte offset "+s);{let e=(7&i)<<18|(63&t[++s])<<12|(63&t[++s])<<6|63&t[++s];e<=65535?n[o++]=e:(e^=65536,n[o++]=55296|e>>10,n[o++]=56320|1023&e)}}}let s="";const i=16384;for(let t=0;t<o;t+=i)s+=String.fromCharCode(...n.slice(t,t+i<=o?t+i:o));return s},exports.bytesToBits=function(t){return t.reduceRight(((t,e)=>{const r=e.toString(2).padStart(8,"0").split("").map((t=>Number(t))).reverse();return t.concat(r)}),[])},exports.bytesToCharts=function(t){return t.length%2!=0?(console.error("Illegal Format UTF16 Code!"),""):t.reduce(((t,e)=>(t.push(String.fromCharCode(e)),t)),[]).join("")},exports.bytesToHex=u,exports.bytesToInt=function(t){if(t.length>6)throw new Error("The number of bytes exceeds 6");const e=new DataView(t.buffer);switch(t.length){case 1:return e.getInt8(0);case 2:return e.getInt16(0);case 4:return e.getInt32(0);default:{let e=c(t);const r=Math.pow(2,8*t.length)/2;return e>=r&&(e%=r,e=-1*(r-e)),e}}},exports.bytesToIntBy128=(t,e=0)=>{let r=0,n=e;for(;n<4&&n<t.length;n++){const o=t[n];if(r|=(127&o)<<7*(n-e),0==(o>>7&1))break}return{num:r,end:n-e<4?n+1:n}},exports.bytesToString=function(t){const e=[],r=t.length;for(let n=0;n<r;n++){const r=t[n].toString(2),o=r.match(/^1+?(?=0)/);if(o&&8==r.length){const s=o[0].length;let i=r.slice(7-s);for(let e=1;e<s;e++)i+=t[e+n].toString(2).slice(2);e.push(String.fromCharCode(parseInt(i,2))),n+=s-1}else e.push(String.fromCharCode(t[n]))}return e.join("")},exports.bytesToUint=c,exports.bytesToUtf8=function(t){const e=[];let r=0;for(;r<t.length;){const n=t[r];n<128?(e.push(String.fromCharCode(n)),r++):n>191&&n<224?(e.push(String.fromCharCode((31&n)<<6|63&t[r+1])),r+=2):(e.push(String.fromCharCode((15&n)<<12|(63&t[r+1])<<6|63&t[r+2])),r+=3)}return e.join("")},exports.checkVersion=n,exports.checkWxVersion=t=>{const e=wx.getSystemInfoSync().SDKVersion;return n(t,e)},exports.clearCache=function(t){const e=h();e[t]&&(e[t]={})},exports.dec2hex=t,exports.firstUpperCase=o,exports.formatQuery=(t,e=!1)=>{if(!t)return"";return Object.keys(t).reduce(((r,n)=>{const o=t[n];return void 0!==o&&r.push(`${n}=${e?encodeURIComponent(o):o}`),r}),[]).join("&")},exports.getCache=function(t,e){const r=h();return r[t]?r[t][e]:null},exports.getCacheSpace=function(t){const e=h();return e[t]?e[t]:null},exports.hex2ab=function(t){const e=[];if("string"==typeof t)for(let r=0;r<t.length;r+=2)e.push(parseInt(t.slice(r,r+2),16));else if("string"==typeof t[0])for(let r=0;r<t.length;r++)e.push(parseInt(t[r],16));return new Uint8Array(e)},exports.hex2dec=function(t){return parseInt(t,16)},exports.hex2string=function(t){const e=[];if("string"==typeof t)for(let r=0;r<t.length;r+=2){const n=parseInt(t.slice(r,r+2),16);e.push(String.fromCharCode(n))}else for(let r=0;r<t.length;r++){const n=parseInt(t[r],16);e.push(String.fromCharCode(n))}return e.join("")},exports.hexToBytes=t=>{if(t.length%2!=0)throw new Error("hex length error");const e=t.length/2,r=new Uint8Array(e);for(let n=0;n<e;n++)r[n]=parseInt(t.slice(2*n,2*n+2),16);return r},exports.int2TwoBytes=function(t){const r=e(255&t);return[e(t>>8&255),r]},exports.intToByte=e,exports.intToBytes=(t,e)=>{const r=new Int32Array([t]),n=new Int8Array(r.buffer);return n.reverse(),e?new Uint8Array(n.slice(4-e)):new Uint8Array(n)},exports.keyToHump=function t(e){return"object"!=typeof e?e:Array.isArray(e)?e.map((e=>t(e))):Object.keys(e).reduce(((r,n)=>{const s=n.split("_").map(((t,e)=>e>0?o(t):t)).join("");let i=e[n];return Array.isArray(i)?i=i.map((e=>t(e))):"object"==typeof i&&(i=t(i)),r[s]=i,r}),{})},exports.randomBytes=t=>{const e=new Uint8Array(t);for(let r=0;r<t;r++)e[r]=Math.floor(256*Math.random());return e},exports.setCache=function(t,e,r){const n=h();n[t]||(n[t]={}),n[t][e]=r},exports.string2bytes=r,exports.stringToBytes=function(t){const e=[],r=t.length;for(let n=0;n<r;n++){const r=t.charCodeAt(n);r>=65536&&r<=1114111?(e.push(r>>18&7|240),e.push(r>>12&63|128),e.push(r>>6&63|128),e.push(63&r|128)):r>=2048&&r<=65535?(e.push(r>>12&15|224),e.push(r>>6&63|128),e.push(63&r|128)):r>=128&&r<=2047?(e.push(r>>6&31|192),e.push(63&r|128)):e.push(255&r)}return new Uint8Array(e)},exports.uintToBytes=(t,e)=>{const r=new Uint32Array([t]),n=new Uint8Array(r.buffer);return n.reverse(),e?n.slice(4-e):n},exports.uintToBytesBy128=t=>{const e=[];do{let r=t%128;(t=parseInt(""+t/128))>0&&(r|=128),e.push(r)}while(t>0);return new Uint8Array(e)},exports.utf8ToBytes=function(t){return r(t,!0)},exports.xxtea=f; |
{ | ||
"name": "@ray-js/wechat-helper", | ||
"version": "0.0.15", | ||
"version": "0.0.16-beta-1", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "access": "public", |
@@ -5,1 +5,2 @@ export * from './lib/helper'; | ||
export * from './lib/xxtea'; | ||
export * from './lib/cache'; |
23140
9
302