You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/MvcShipping/Viewsjs/CRM_QUOTATION/encrypt.min.js

1 line
1.2 KiB
JavaScript

2 years ago
function encrypt(c,e){if(null==e||0>=e.length)return null;for(var a="",b=0;b<e.length;b++)a+=e.charCodeAt(b).toString();var b=Math.floor(a.length/5),d=parseInt(a.charAt(b)+a.charAt(2*b)+a.charAt(3*b)+a.charAt(4*b)+a.charAt(5*b)),k=Math.ceil(e.length/2),h=Math.pow(2,31)-1;if(2>d)return null;for(var f=Math.round(1E9*Math.random())%1E8,a=a+f;10<a.length;)a=(parseInt(a.substring(0,10))+parseInt(a.substring(10,a.length))).toString();for(var a=(d*a+k)%h,g="",l="",b=0;b<c.length;b++)g=parseInt(c.charCodeAt(b)^Math.floor(255*(a/h))),l=16>g?l+("0"+g.toString(16)):l+g.toString(16),a=(d*a+k)%h;for(f=f.toString(16);8>f.length;)f="0"+f;return l+f}function decrypt(c,e){if(!(null==c||8>c.length||null==e||0>=e.length)){for(var a="",b=0;b<e.length;b++)a+=e.charCodeAt(b).toString();var d=Math.floor(a.length/5),d=parseInt(a.charAt(d)+a.charAt(2*d)+a.charAt(3*d)+a.charAt(4*d)+a.charAt(5*d)),k=Math.round(e.length/2),h=Math.pow(2,31)-1,b=parseInt(c.substring(c.length-8,c.length),16);c=c.substring(0,c.length-8);for(a+=b;10<a.length;)a=(parseInt(a.substring(0,10))+parseInt(a.substring(10,a.length))).toString();for(var a=(d*a+k)%h,f="",g="",b=0;b<c.length;b+=2)f=parseInt(parseInt(c.substring(b,b+2),16)^Math.floor(255*(a/h))),g+=String.fromCharCode(f),a=(d*a+k)%h;return g}};