jh-iking-utils
Version:
金合前端工具库
2 lines (1 loc) • 2.38 kB
JavaScript
import*as t from"crypto-js";export{t as Cryptojs};export{default as dayjs}from"dayjs";const n=(n,e="1234567890000000",r={mode:t.mode.CBC,padding:t.pad.Pkcs7})=>{const i=t.enc.Utf8.parse(e),o=t.enc.Utf8.parse(e),c=t.enc.Utf8.parse(n),u={iv:o,...r};return{AES:{encrypt:()=>t.AES.encrypt(c,i,u).toString(),decrypt:()=>t.AES.decrypt(n,i,u).toString()},DES:{encrypt:()=>t.AES.encrypt(c,i,u).toString(),decrypt:()=>t.AES.decrypt(n,i,u).toString()},TripleDES:{encrypt:()=>t.AES.encrypt(c,i,u).toString(),decrypt:()=>t.AES.decrypt(n,i,u).toString()},RC4:{encrypt:()=>t.AES.encrypt(c,i,u).toString(),decrypt:()=>t.AES.decrypt(n,i,u).toString()}}},e={1:"低",2:"较低",3:"一般",4:"较高",5:"高",6:"强"},r=(t,n)=>{const r=t.length;let o=i(t);return r>=8?{leave:++o,desc:e[o]}:n?{leave:r>=n?o:1,desc:e[1]}:r>=6?{leave:o,desc:e[o]}:{leave:1,desc:e[1]}},i=t=>{let n=1;return/[A-Z]+/.test(t)&&n++,/[a-z]+/.test(t)&&n++,/\d+/.test(t)&&n++,/\~|\.|\,|\?|\!|\@|\#|\$|\%|\^|\&|\*|\_|\/|\+|\-+/.test(t)&&n++,n},o=Object.prototype.toString;function c(t,n){return o.call(t)===`[object ${n}]`}function u(t){return void 0!==t}function s(t){return!u(t)}function p(t){return null!==t&&c(t,"Object")}function f(t){return null===t}function a(t){return c(t,"String")}function d(t){return"function"==typeof t}function l(t){return t&&Array.isArray(t)}const y="undefined"==typeof window,S=!y;var g=Object.freeze({__proto__:null,isDef:u,isUnDef:s,isObject:p,isEmpty:function(t){return l(t)||a(t)?0===t.length:t instanceof Map||t instanceof Set?0===t.size:!!p(t)&&0===Object.keys(t).length},isDate:function(t){return c(t,"Date")},isNull:f,isNullAndUnDef:function(t){return s(t)&&f(t)},isNullOrUnDef:function(t){return s(t)||f(t)},isNumber:function(t){return c(t,"Number")},isPromise:function(t){return c(t,"Promise")&&p(t)&&d(t.then)&&d(t.catch)},isString:a,isFunction:d,isBoolean:function(t){return c(t,"Boolean")},isRegExp:function(t){return c(t,"RegExp")},isArray:l,isWindow:function(t){return"undefined"!=typeof window&&c(t,"Window")},isElement:function(t){return p(t)&&!!t.tagName},isMap:function(t){return c(t,"Map")},isServer:y,isClient:S,isUrl:function(t){return/(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/.test(t)}});export{g as is,n as passwordEncry,r as passwordValid};