function Base64Encode(r){return CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(r))}function Base64Decode(r){return CryptoJS.enc.Base64.parse(r).toString(CryptoJS.enc.Utf8)}function AESEncrypt(r,t,e){var t=CryptoJS.enc.Utf8.parse(t);var e=CryptoJS.enc.Utf8.parse(e);var n=CryptoJS.AES.encrypt(r,t,{iv:e,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return n.toString()}function AESDecrypt(r,t,e){var t=CryptoJS.enc.Utf8.parse(t);var e=CryptoJS.enc.Utf8.parse(e);var n=CryptoJS.AES.decrypt(r,t,{iv:e,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return n.toString(CryptoJS.enc.Utf8)}function AESEncryptECB(r,t){var t=CryptoJS.enc.Utf8.parse(t);var e=CryptoJS.AES.encrypt(r,t,{mode:CryptoJS.mode.ECB,padding:CryptoJS.pad.Pkcs7});return e.toString()}function AESDecryptECB(r,t){var t=CryptoJS.enc.Utf8.parse(t);var e=CryptoJS.AES.decrypt(r,t,{mode:CryptoJS.mode.ECB,padding:CryptoJS.pad.Pkcs7});return e.toString(CryptoJS.enc.Utf8)}function DESEncrypt(r,t,e){var t=CryptoJS.enc.Utf8.parse(t);var e=CryptoJS.enc.Utf8.parse(e);var n=CryptoJS.DES.encrypt(r,t,{iv:e,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return n.toString()}function DESDecrypt(r,t,e){var t=CryptoJS.enc.Utf8.parse(t);var e=CryptoJS.enc.Utf8.parse(e);var n=CryptoJS.DES.decrypt(r,t,{iv:e,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return n.toString(CryptoJS.enc.Utf8)}function DESEncryptECB(r,t){var t=CryptoJS.enc.Utf8.parse(t);var e=CryptoJS.DES.encrypt(r,t,{mode:CryptoJS.mode.ECB,padding:CryptoJS.pad.Pkcs7});return e.toString()}function DESDecryptECB(r,t){var t=CryptoJS.enc.Utf8.parse(t);var e=CryptoJS.DES.decrypt(r,t,{mode:CryptoJS.mode.ECB,padding:CryptoJS.pad.Pkcs7});return e.toString(CryptoJS.enc.Utf8)}function SHA256(r){var t=CryptoJS.SHA256(r).toString(CryptoJS.enc.Hex);return t}function MD5(r){var t=CryptoJS.MD5(r).toString(CryptoJS.enc.Hex);return t}function SHA1(r){var t=CryptoJS.SHA1(r).toString(CryptoJS.enc.Hex);return t}function SM2Encrypt(r,t,e){if(e==null)e="1";return SM2Utils.encs(t,r,e)}function encryptFormPassword(r){var t=$(r).serializeArray();var e=$(r).find('input[type="password"]').length;var n=0,p=$(r).attr("data-secret");if(!p)return t;var o=p.split(":",2);p=o[0];for(var a=0;a<t.length;a++){var i=t[a];if($(r).find('input[name="'+i.name+'"][type="password"]').length>0){if(i.value!=""){var S=i.value;if(o.length==2)S=JSON.stringify({p:S,e:o[1],t:(new Date).getTime()});t[a].value=SM2Encrypt(S,p)}n++;if(n>=e)break}}return t}function submitEncryptedData(p,o,a){$(p).on("submit",function(r){r.preventDefault();var t=$(this).find(":submit");if(t.children("fa-refresh").length>0)return;var e=encryptFormPassword(this);if(o)e=o(this,e);t.prepend('<i class="fa fa-refresh fa-spin"></i>');t.prop("disabled",true);var n=function(){t.children(".fa-refresh").remove();t.prop("disabled",false)};$.post($(this).attr("action"),e,function(r){n();if(r.Code==1){if(a)return a(r);if(r.URL){if(r.Info){App.message({title:App.i18n.SYS_INFO,text:r.Info,class_name:"success"});window.setTimeout(function(){window.location=r.URL},2e3);return}window.location=r.URL}else{App.message({title:App.i18n.SYS_INFO,text:r.Info?r.Info:App.i18n.SUCCESS,class_name:"success"})}}else{App.captchaUpdate($(p),r);App.message({title:App.i18n.SYS_INFO,text:r.Info?r.Info:App.i18n.FAILURE,class_name:"danger"});$(p).trigger("submiterror")}},"json").error(function(r,t,e){n();if(!e)e=App.t("网站不可用，请刷新页面后重试");App.message({text:e,type:"error"});$(p).trigger("submiterror")})})}