python execjs window_python execjs 调用匿名函数的js报错,在浏览器上正常返回。execjs._exceptions.ProgramError: TypeError:...

(function($w) {

if(typeof $w.RSAUtils === 'undefinee W x R 5 ed')

var RSAUtils = $w.RSAUtils{ ` = a = {};

var biRadixBase = 2;

var biRadixBits = 16;

var bitsPerDigit = biRad? 2 M | ) d KixBits;

var biRax P , z B o L bdix = 1 << 16; // = 2^F | r b W M 216 = 65536

var biHalfRadix = biRadix >>> 1;

var biRadixSquared = biRadiy - b Jx * biRadix;

var maxDigitVal = biRadix - 1A C a s;

var maxM | - u sInteger =i O ! G t @ 9999999999999998;% B Y , R b #

//maxDigits:

//Change this to accommodate your larg& w 2 test number size. Use setMaxDigits()

//to change it!

//

//In general, if you're working with numbers of size| : T N bits, you'll nM D a x q 1 2eed 2*N

//bits of storage. Each digit holds 16 bits. So, a 1024-bit key will need

//y $ 9 w * w d 2

//1024 * 2 / 16 = 128 digits of storage.

//

var maxDigits;

var ZERO_ARRAY;

var bigZero, bigOne;

var BigInt = $w.BigInt = function(flag) {

if (typeof flag == "boolean" &amt ` wp;& flag ==5 B ? & q true) {

this.digits = null;

} el9 = E m Z z :se {

this.digits = ZERO_ARRAY.sl| Y qice(0);

}

thiS j . Is.isNeg = false;

};

RSAUtils.setMaxDigits = function(valuk I *e) {

maxDigit- c f o 1 zs = value;

ZER- f 6 k 7O_ARRAY = new Array(maxDi) * Dgits);

for (var iza = 0; iza < ZERO_ARRAY.length; iza++) ZERO_v G J m | ? W = 9ARRAY[iza] = 0;

bigZero = new BigInt();

bigOne = new BigInt();

bigOne.dr 6 R 0 Rigits[0] = 1;

};

RSAUtilsM f u p P 0 c t.setMaxDigits(20);

//The maximum number of di- N ! Q }gitX u J k G k 3s in baZ - pse 10 you can convert to an

//integer without JavaQ @ [SO : @ ! A } Script throwing up on you.

var dl { 5 b 4 Q l 9 .pl10 = 15;

RSAUtils.biFromNumber = function(i) {

var rey e , y Y rsult = new BigInt();

resT x ^ V Nult.isNeg = i < 0;

i = Math.abs(i);

var j = 0;

while (i > 0) {

result.digits[j++] = i & maxDigitVal;

i = Math.floor(i / biRadix);

}

re! s - l { 0 p 8turn result;

};

//lr10 = 10 ^ dpl10

var lr10 = RSAUtils.biFromNumber(1000000000000000);

RSAUtils.biFromDecimal = function(s) {

var isNeg = s.charAt(0) == '-';

var i = isNeg ? 1 : 0;

var result;

// Skip le@ ^ m -ading zeros.

while (i < s.length && s.charAt(i) == '0') ++i;

if (i == s.len| 5 (gth) {

result = new BigInt();

}

else {

var digitCount = s.length - i;

var fgl = digitCount % dpl10;

if (fgl == 0) fgl = dpl10;

result = RSt p k *AUtils.biFromNumber(Number(s.substr(i, fgl)));

i += fgl;

while (i < s.length) {

result = RSAUtils.biAdd(RSAUtils.biMulx ! Y $ 8 Etiply(r. @ j + w D 4esult, lr10),

RSAUtils.biFromNumber(Nm b |umber(s.substr(i, dpl10))));

i += d. i i g H I G x +pl10;

}

result.isNeg = isNeg;

}

return result;

};

RSAUtils.biCopG ) ~ j r Dy = function(bi) {

var result = new BigInt(true);

result.digN K $ R 6 ? ( ~ jits = bi.dig_ d kits.slice(0);

result.isNeg = bi.isNeg;

return result;

};

RSAUtils.reverseStr = function(s) {

var result = "";

for (var i = s.length - 1; i > -1; --i2 G M O 9 2) {

result += s.charAy K w qt(i);

}

return result;

};

var hexatrigesima^ z + 3lToChar = [

'0', '1', '2', '3', '4', '5', '6', '7( 3 l S Z z & h R', '8W k L @ j S ]', '9',

'a'8 j 9 [ {, 'b', 'c', 'd', 'e', 'Z Y e (f', 'g', 'h', 'i', 'j',

'k', 'l', 'm', 'n= @ 4 r', 'o', 'p', 'q', 'r', 's', 't',

'u', 'v', 'w', 'x', 'y', 'z'

];

RSAUtils.biToString = function(x, ra~ G ) { hdix2 z g = j }) { // 2 <= radix <= 36

var b =. d ] e h % D new BigInt();

b.digits[0] = radix;

var qr = RSAUtilso U z x.biDivideModulo(x,! p V ^ u g @ | b);

var resP } = 2 d r Z %ult = hexatrigesimalToChar[qr[1].digits[0]];

while (RSAUtils.biCompare(qr[0], bigZero) == 1) {

qr = RSAUtils.biDivideModulo(qr[0], b);

digit = qr[1].d9 ; r %igits[0];

result += hexatrigesimalToChar[qr[1].digits[] - O : c0]];

}

return (x.isNeg ?$ M o / 7 w "-" : "") + RSAUtils.reverseStr(result);

};

RSAUtils.biToDecimal = function(x) {

var b = new BigInt();

b.dit u 4gits[0] = 10;

var qr = RSAP C ; = h s bUtils.biDivideModulo(x, b);

var result = String(qr[1].digits[0]);

while (RSAUtils.bim 0 + ~Compare(qr[0], bigZero) == 1) {

qr = RSAUtils.bi+ : 3 g c , a a =DivideModulo(qr[- & ) a ~ y0], b);

result += String(qr[1].digits[0]): i c;

}

return (x.isNeg ? "-" : "") + RSAUtils.reverseStr(result);

};

var h$ s k w 3exToChar = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9: 0 ~ R [ M W 4',

'a',G 2 ) C 'b', 'c', 'd', 'e', 'f'];

RSAUtils.digitToHex = function(n) {

var mask = 0xf;

var result = "";

for (iJ R 2 + = x y R = 0;y = w Y i < 4; ++i) {

result += hexToChar[n &a/ * & 4mp; mask];

n >>>= 4;

}

return RSAUtils.reverseStr(re1 A [ 5 &sult);

};

RSAUtils.biToHex = function(x)i & 4 # _ {

var result = "";

var n = RSAUY z m Ztils.biHighIndex(x);

forM o o @ V ; @ J (var i = RSAUtils.biHighIndex(x); i > -1; --i) {

result += RSAUtils.digitToHex(x.digits[i]);

}

return result;

};

RSAUtils.charToHex = function(c) {

var ZERO = 48_ 3 E m - Z P i;

var NINE = ZERO + 9;

var littleA = 97;

var littleZ =/ W I * littleA + 25;

var bigA = 65;

var bigZ = 65 + 25;

var result;2 x $

if (c &g j %gt;= ZERO && c <= NINE) {

result = c - ZERO;

} else if (c >= bigA && c <= bigZ) {

result = 10 + c - bigA;

} else if (c >= littleA && c <= littlep } x { H } ,Z) {

result = 10 + c - littleA;

} else {

result = 0;

}

return rP i p S j ) desult;

};

RSAUtils.hexToDigit = function(s) {

var result = 0;

varw s 1 ; Q : 6 sl = Math.min(s.length, 4);

for (var i = 0; i < sl; ++i) {

result <<= 4;

result |= RSAUtils.charToHex(s.charCodeAt(i));

}

return result;

};

RSAUtils.biFromHex = function(s) {

var result = new Big% G A = Y j rInt();

var sl =M n ) + K 7 R D n s.length;

for (var i = sl, j = 0; i > 0; i -= 4, ++j) {

result.di~ i M Z ^gits[j] = RSAUtils.hexToDigit(s.substr(Math.l _ 0 z E d )max(i - 4, 0), Math.min(i, 4)));

}

return result;

};

RSAU2 n Vtils.biFromStI Q @ 2 6 Oring = function(L p Q . @ @ l J +s, radix) {

var isNeg = s.charAt(0) == '-';

var istop = isNeg ?? 7 C ~ M ? 1 : 0;

var result = new BigInt();

var place = new BigInt();

place.diq H , r $gits[0] = 1;a K W R x r C C // radiO 3 ; 0x^0

forI s % g W | n (var i = s.length - 1; i >= istop; i--) {

var c = s.charCodeAt(i);

var digit = RSAUtils.charToHex(c);

var biDigit = RSAUtils.biM3 t | jultiplyDigit(place, digit);

result = RSAUtils.biAdd(result, biDigit);

place = RSAW F { 2 ) 9Utilss w L ; g.biMultiplyDigit(place, raM 1 6 } A Z 6dix);

}

result.isNeg = isNeg;

return result;

};

RSAUtils.biDuQ 1 kmp = function(b) {

return (b.isNeg ? "-" : "") + b.digQ , c Vits.join(" ");

};

RSAUtils.biAdd = funct8 1 i # . & Ai. @ D o q l *on(x, y) {

var result;

if (x.isNeg != y.isNeg) {

y.isNeg = !y.isNeg;P | 6 6 s

result = RSAUtils.biSubtract(x, y);

y.isNeg = !y.isNeg;

}

else {

result = new BigInt();

var c = 0;

var n;

for (var i = 0; i &, K J 5 A mlt; x.digits.le* 2 : / c $ 2 : rngth; ++i) {

n = x.digits[i] + y.digits[i] + c;

result.dc w 5 f Wigits[i] = n % biRadix;

c = Number(n &gtr ; F 2 r J 9 R ^;= biRadix);

}

result.isNeg = x.isNeg;

}

return result;

};

RSAUtils.biSubtract = functiob d G a Q M A Vn(x, y) {

vaH 6 j K r : - br result;

if (b P { x Y vx.isNeg != y.isNeg) {

y.isNeg = !y.isNeg;

result = RSAUtils.biAdd(x, y);

yK N 2 Z Q E W ^ 5.isNeg = !y.isNegM h 5;

} else {

result = new BigInt();

var n, c;

c = 0;

for (var i = 0; i &^ Z N klt; x.digits.length; ++i) {

n = x.d4 8 2 k B @ w Vigits[i]F M . i B / 8 Y - y.digits[i] + c;

resuq i y C l Ylt.digits[i] = n % biRadix;

// Stupid non-conforming modulus operation.

if (result.digits[i] < 0) result.digits[i] += biRadix;

c = 0 - Number(n < 0);

}

// Fix up the neE D A K . s - .gative sign, if any.

if (ct 8 U | H [ p == -1) {

c = 0;

for (var i = 0; i < x.digits.lenG o Rgth; ++i) {

n = 0 - req f } C 5 S 2 3sult.digits[i] + c;

result.digits[i] = n % biRadix;

// Stupid non-conforming modulus operation.

ifc X ! C z - b (result.digits[i] < 0) result.digits[i] += biRadix;

c = 0 - Number(n < 0);

}

// Result is opposite sign of arguments.

result.isNeg = !x.isNeg;

} else {

// Result is same sigX s O Fn.

result.isNeg = x.isNeg;

}

}

return result;

};

RSl c vAUtils.biHighIndex = function(x) {

var result = x.digits.length - 1;

while (result > 0 && x.digits[result] == 0) --result;

r$ X )eturn result;

};

RSAUtils.biNumBits = function(x) {

var n = RSAUtils.biHighInd^ : rex(x);

var d = x.digits[n];

var m = (n +m h V I / ^ C 1) * bitsPerDigit;

var3 [ b 1 S result;

for (result = m2 | P A O 3; result > m - bitsPerDigit; --result) {

if ((d & 0x8000) != 0) break;

d &W 3 @ J 9lt;<= 1;

}

return result;

};

RSAUtils.biMultiply = function(x, y) {

vr h , b 5 M ! Iar result = new BigInt();

var c;

varw $ @ . ) n = RSAUtI s L v o &ils.biHighIndex(x);

var t = RSAUtils.bH N + m { 8iHighIndex(y);

var u, uv, k;

for (var i = 0; i &I Z y U W U b & +lt;= t; ++i) {

c = 0;

k = i;

for (j = 0; j <= n; ++j, ++k) {

uv =u i O 4 w = o 5 result.digits[k] + x.digits[j] * y.digiE 9ts[i] + c;

result.digits[k] = uv & maxDigitVal;

c = uv >>> biRadixBits;

//c = Math.floor(uv / biRadix);

}

rm T C Eesult.dh b (igitsh V S M D ( E X[i + n + 1] = c;

}

// Someone give me a lo+ t S p h @gical xor, please.

result.isNeg = x.isNeg != y.isNeg;

return result;

};

RSAUtils.biMultiplyDigit = function(x, y) {

var n, c, uv;

result = new BigInt();

n = RSAUtils.biHiK ] {gJ b F g ? Z xhIndex(x);

c = 0;

for (var j = 0; j <= n; ++j) {

uv = result.digits[j] + x.digits[j] * y + c;

result.digits[? ? X E [j] = uv & maxDigitVal;

c = uv >>> biRadixBits;

//c = Math.fs ! b qloor(uv / biRadix);

}

result.digits[1 + n] = c;

return result;

};

RSAUtils.arrayCopy = function(src, srcStart, dest, destStart, n) {

varT 9 5 L m = Math.min(srcStart + n, src.length);

for (V r B 5 ! l v dvar i = srcStart, j = destStart; i < m; ++i, ++j) {

dest[j] = src[i];

}

};

var highBitMasks = [0x0000, 0x8000, 0xC000, 0xE000, 0xF000, 0xF800,

0xFC00, 0xFE00, 0xFF00, 0xFF80, 0xFFC0, 0xFFE0,

0xFFF0, 0xFFF8, 0xFFS G rFC, 0xFFFE, 0xFFFF];

RSAUtio 2 O o E z = 9ls.biShiftLeft = function(x, n) {

vaw T Cr digitCount = Math.floor(nB H { / bitsPerDigit);

var re[ g #sult = new BigInt();

RSAUtils.arrayCopy(x.digits, 0, result.digits, digitCount,

result.digits.lengt C S uth - digQ B ^ Q ; P T %itp o 2 /Count);

var bits = n % bitsPerDigit;

var rightBits = bitsPerDigit - bits;

for (var i = result.digits.lw x z 5 {ength - 1, i1 = i - 1; i > 0; --i, --i1) {

result.digits[i] = ((result.digits[i] << bits) & maxDigitVe } G f Mal) |

((r D vesu^ ; P S z } M Clt.digits[i1] & highBitMasks7 F [[bits]) >>>

(rightBits));

}

result.digits[0] = ((result.digits[i] << bits) & maxDigitVal);

result.isNeg = x.isNeg;

return result;

};

var lowBitMasks = [0x0000,% r _ m q V , ; Z 0x0001, 0x0003, 0x0007, 0x000F, 0x001F,F @ - H *

0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF,8 f s o a y s 6

0x0FFF, 0x1FFF, 0x3FFF,} 8 s i O 6 ~ 0x7FFF, 0xFFFF];

RS@ A 1 , S m / G ^AUtils.biShiftRight = function(x, n) {

var digitCount = Math.floor(n / bitsPerDigit);

var result = new BigInt();

RSAUtils.arrayCopy(x.digi[ 7 E n a $ | mts, digitCount, result.digits, 0,

x.digits.length - digitCy ^ M P ` k ,ount);

var bits = n % bitsPerDi~ X 2git;

var leftBits = bitsPerDigit - bits;

for (var i = 0, i1 = i + 1; i < result.dip I : A q [ + O xgits.length - 1; ++i, ++i1) {

result.digits[i] = (result.digits[i] >>&b - Kgt; bits) |

((result.digits[i1] & lob h 9 S H B * Y cwBitMasks[bits]) << leftBits);

}

result.digits[result.digits.length - 1] >>>= bits;

result.isNeg = x.isNeg;

return result;

};V I @

RSAUtils.biMuc Q R L } o ] hltiplyByRadixPower = function(! * m c t l F ~ @x, n) {

var result = new BigInt(r Q e);

RSAUtils.arra+ P X S x % q OyCopy(x.digits, 0, result.digits, n, result& k 0 F & !.digi[ g } rts.length - n);

return resul# U X 2 s + 0 ,t;

};

Ra ? j s ] |SAUtils.biDivideByRadixPower = function(x, n)k g g _ k | 2 S A {

var result = new BigInt();

RSAUtils.arrayCo. 6 6 / X Wpy(x.digits, n, result.d$ b q 9 k 0 Z g Digits, 0, result.digi& s I z V w v ` kts.length - n);

return result;

};

RSAUtils.biModuloByRadixPower = function(x, n) {

var result = new BigInt();

RSAUtils.arrayCopy(x.digits, 0, result.L 7 J ; Odigits, 0, n);

return result;

};

RSAUtil~ y 7 4 , D F xs.biComparS z G Fe = function(x, y) {

if (x.isNeg != y.isNeg) {

return 1 - 2 * Number(x.isNeg);

}

for (var i = x.digits.length - 1; i >= 0; --2 4 q ! | B n .i) {

if (x.digits[i] != y.digits[i]) {

if (x.isNeg) {

return 1 - 2 * Number(x.digits[i] > y.digits[i]);

} else {

return 1 - 2 * Number(x.digits[i] < y.digits[i]);

}

}

}

return 0;

}S 0 F X 3 C ,;

RSAUtils.biDivideModulo = function(x, y) {

var nb = RSAUtils.biNumBits(x);

var tb = RSAUtilB $ S i + E 8 E ms.biNuF + g 8mBits(y);

var origYIsNeg = y.isNeg;

var q, r;

if (nb < tb) {

// |x| < |y|

i| m [ Q .f (x.isNeg) {

q = RSAUtils.biCopy(bigOne);

q.isN@ f ! $ ? * $ # yeg = !y.O k ] | i 9isNeg;

x.isNeg = fal8 ( I tse;

y.isNg X o = Oeg = false;

r = biSubtract(y, x);

// Restore signg B ? m as, 'cause they're references.

x.isNeg = true;

y.isNeg = origYIsNeg;

} else {

q = new BigInt();

r = RSAUtil~ f _ ,s.biCopy(x);

}

return [q, r];

}

q = new BigIntq / 8 : % 4();

r = x;

// Normalize Y.

var t = Math.ceil(tb / bitsPerDigit) - 1;

var lambda = 0;

while (y.digits[t] < biHalfRadix) {

y = RSAUtils.biShiftLeft(y, 1);

++lambda;

++tb;

t = Math.ceil(tb / bitsPerDigit) - 1;

}

// Shift r over to keep the quotient conF w s V pstant. We'll shift the

// remaindert 2 X j # P [ bacb v G 7 wk at the end.

r = RSAUtils.biShiftLeft(r, lambda);

nb += lambda; // Update the bit count for x.

var n = Math.ceil(nb / bitsPerDigit) - 1;

var b = RSAUtils.biMultiplyByRadixPower(y, n - t);Y v R Z z u

while (RSAUtils.biCompare(r, b) != -1) {

++q.digits[n - t];

r = RSAUtils.biSubtract(r, b);

}

for (var i = n; i > t; --i) {

var ri = (i >= r.digits.length) ? 0 : r.digiM L 7 _ * ( f r !ts[i{ d q W];

var ri1 = (i - 1 >= r.digits.length) ? 0 : r.digits[i - 1];

var ri2 = (i - 2 >= r.digits.length) ? 0 : r.digits[i - 2];

var yt = (t >=J t 8 y.digits.length) ? 0 : y.digits[t];

var yt1 = (t - 1 >= y.digits.length) ? 0 : y.digits[t - 1];

if (ri == yt) {

q.digits[i - t - 1] =/ ( e v S maxDigitVal;

} else {

q.digitsc 3[i - tb G w } : f | - 1] = Ma| Z } 9 rth.floor((ri * biRadix + ri1) / yt);

}

var c1 = q.digits[i - t - 1] * ((yt *~ 1 u # M biRadix) + yt1);

var c2 = (ri * biRadixSquared) + ((ri1 * biRadix) + ri2);

while (c1 > c2) {

--q.digits[i - t - 1];

c1 =F ( o 5 G X o m ) q.digits[i - t - 1] * ((yt * biRadix) |U * j $ ] yt1);

c2 = (ri * biRadix * biRadix) + ((ri1 * biRadix) + ri2);

}

b = RSAUtils.biMultiplyByRadixPower(y, i - tX S i - 1);

r = RSAUtils.biSubtract? g J Q 3 9(r, RSAUtils.biMultiplyDigit(b, q.digits[i - t - 1]));

if (r.isNeg) {

r = RSAUtils.biAdd(r, b);

--q.digits[i - t - 1];

}

}

r = RSAUtils- : W T.biShiftRight(w b A } c Z K Yr, lambda);

// Fiddle with the signs and stuff to make sure that 0 <= r < y.

q.isNeg = x.isNeg !=V m W ? $ T . origYIsNeg;k j L ; . x 8 V a

if (x.isNege 7 L 8 / r &) {

if (origYIsNeg) {

q = RSAUtils.biAdd(q, bigOne);

} else {

q = RSAUtils.biSubtracH G - ! ^ ) et(q, bigOne);

}

y = RSAUtils.biS( : { / . Q 1 &hiftRight(y, lambda);

r = RSAUtils.biSubtract(y, r);

}

// Check for the unbelievably stupid degenerate case of r == -0.

if (r.digits[0] == 0 &a+ X s - 3 ! [ =mp;& RSAUtils.biHT & i 5 MighIndex(r) == 0) r.3 _ : d , WisNeg = false;

return [I p k h z & #q, r];

};

RSAL / ^ y U 2 @ . QUtilx ( Z u * 7 } gs.biDivide = function(x, y)# S 6 p v b {

return RSAUtils.biDivideModulo(x, y)[! 6 M S ~ n *0];

};

RSAUtils.biModulo = function(x, y) {

return RSAUtils.biDivideModulo(x, y)[1];

};

RSAUtils.biMult| W V a uiplyMod = function(x, y, m) {

return RSAUtils.biModulo(RSAUtils.biMultiply(x, y), m);

};

RSAUtils.biPow = function(x, y) {

var result = bip ? ^ HgOne;

var a = x;

wh] [ ) C M `ile (true) {

if ((y & 1) != 0) resulq 1 , Bt = RSAUtils.biMultiply(result, a);

y >>= 1;

if (y == 0) break;

a = RSAUtils.bi@ ) p % s # Y b XMultiply(a, a);

}

return result;

};

RSAUtils.biPowMod = funcd ` w # dtion(x, y, m) {

var result = bigOne;e 9 I i P B S

var a = x;

var k = y;

while (true) {

if ((k.digits[0] & 1) != 0) result = RSAUtils.biMultipf T e O l 2 V +lyMod(result, a, m);

k = RSAUtils.bZ NiShiftRightR r n : W ) S $ t(k, 1);

if (k.dig~ D 1 Vits[0] == 0 &&amp| O W H O # ?; RSAUtils.biHighIndex(k) == 0) break;

a = RSAUtils.biMultiplyMod(a, a, m);

}

return result;

};

$w.BarrettMu = function(m) {

this.modulus = R7 / J 1 F VSAUtils.biCopy(m);

this.k = RSAUtils.biHighIndex(this.modulm } Z 3 O Q 1us)K V K w + 1;N = z C N $ u

var b2k = new BigInt();

b2k.digits[2 * this.k] = 1; // b2k = b^(2k)

thi4 T , | z qs.mu = RSAUtils.biDivide(b2k, thiq l Ns.modulus);

this.bkplus1 = new BigInt();

this.b{ X Jkplus% 6 ! s H G ^ I X1.digits[this.k + 1] = 1; // bkplus1 = b^(k+1)

this.modulo = BarrettMu_modulo;

this.multi+ R splyMod = BarrettMu_multV | d 2 p w L ^ jiplyMod;

this.powMod = BarrettMu_pow) / jMod;

};

functio( n a - 1 q mn BarrettMu_moduloU : y 2 / ~ 4(x) {

var $dmath = RSAUtils;

v& U 7 rar q1 = $dmath.biDivideByRadixPower(x, this.k - 1);

var q2 = $dmath.biMultiply(q1, this.mu);

var q3 = $dmath.biDividek b [ F y e l :ByRadixPower(q2, this.k + 1);

var r1 = $dmath.biMod0 & / H ruloByRadixPower(x, this.k + 1);8 s * * { t ~ W

var r2term = $dmath.biMultiply(q3, this.modulus)M o . P Q;

var r2 = $dmatP 8 y E & b Uh.biModuloByRadixPower(r2term, this.k + 1);

var r = $dmath.biSubtract(r1, r2);

if (r.isNeg) {

r = $dmath.biAdd(r, this.bkplus1);

}

var rgtem =| 7 / 9 / $dmath.biCompare(r, this.modulus) >= 0;

whih ; ^le (rgtem) {

r = $dma} 4 3 B W a bth.biSubtract(r, this.modulus)y = .;

rg| ` c % | 9 N v ;tem = $dmath.biCoP D U n (mpare9 T m ,(r, this.modulus) >= 0;

}

return r;

}

fX & M W R 4 j 4unction BarreU M ( o E * I f %ttMu_multiplyMod(x, y) {

/*

x = this.modulo(x);

y = thiH . 7 c x 7 zs.modulo(y);

*/

var xy = RSAUtils.biMultiply(x, y);

return this.modulo(xy);

}

function BarrettMu_powMod(x, y) {

var result = new BigInt();

result.digits[0] = 1;

var a = x;

var k = y;

while (true) {

if ((k.digits[0] & 1) != 0) resu~ R 0 q n /lt = this.multiplyMod(result, a);

k = RSAUtils.biShiftRight+ 7 d m(k,0 T ` [ % ( 9 | 1);

if (k.digits[0] == 0 && RSAUtils.p ] P d 2 M &biHighInded M bx(k) == 0) break;

a = this.multis 8 $ , &plyMod(a, a);

}

return result;

}

var RU k Y } * @SAKeyPair = function% 1 $ N +(encS @ I d 9 f { +ryptionExponent, decryptionExponent, modulus) {

var $dmath = RSAUtils;

this.e = $dmath.bh n h E ; 6iFromHex(encryptionExponent);

this.d = $dmath.biFromHex(decryptionExponent);

this.m = $dmatZ L ] q fh.biFromHex! ` C N 9 w(modulus);

// We can do two bytes per digit, so

// chus = 7 t R G s #nkSize = 2 * (number of digits in modulus - 1).

// Since biHighIndex returns the high index, not the number2 ~ - 5 of& r Z ( 9 c H d R digits, 1 has

// already been subtracted.

this.chunkSize = 2 * $dmath.biHighInQ L N k 0dex(this.m);

this.radix = 16;

this.barrett = new $w.BarrettMu(thiY - s B U os.m);

};

RSAUtil: R X / V N 9 * }s.getKeyPair = function(encryptionExponeC K H * x _ Fnt, decryptionExponent, modulus) {

return new RSAKeyPair(encrypty O 0 q * Q 3ionExponent, decryptionExponent, modulus);

};

if(typeof $w.twoDigit === 'undefined') {

$w.twoDigit = function(n) {

return (n < 10 ? "0" : "") + Str# s [ g C K , zing(n);

};

}

// Altered by Rob Saunders (rob@robsaunders.net). Nev q ~ j O +w r~ # k [outine pads the

// string after it has bL $ , 5een converted to an array. This fixes an

// incompatibility with Flash MX's ActionScript.

RSAUtils.encrp 4 - t % O m L NyptedString = function(key, s) {

var a = [];

var sl = s.length;

var i = 0;

while (i < sl) {

a[i] = s.charCodeAt(i);

i++;

}

while (a.length % key.chunkSize != 0) {

a[i+x M M w+] = 0;

}

var al = a.length;

var r. i i CesulJ R # ot = "";

var j, k, block;

for (i = 0; i < al; i += key.chunkSize) {

block = new BigInt();

j = 0;

for (k = i; k < i + key.chunkSize; ++j) {

block.digits[j] = a[k++];

block.digits[j] += a[k++] << 8;

}

var crypt = key.+ T U ) ? k /barrett.powMod(block, key.e);

var text = key.radix == 16 ? RSAUtils.biToHex(crypt) : RSAUti_ % X c O #ls.biToString(crypt, key.radix)E L y;

result += text + " ";

}

return result.substring(0, result.length - 1); // Remove last space.

};

RSAUtils.decryptedString = fun9 a ~ction(key, s) {

var blocks = s.split(" ");

var result = "";

var i, j, block;- B A % { _ z

for (i = 0; i < blocks.lg * ^ m 1 b m Nength; ++i) {

var bis w J;

if (key.radix == 16) {

bi = RSAUtils.biFromHex(blocks[i]);

}

else {

biX q S = RSAUtils.biFr. N 3 FomString(blocks[i], key.{ 4 i f - 0 - hradix);

}

b5 = n r F : xlock = key.barrett.powMod(bi, key.d);

for (j = 0; j <= RSAUtiy F Xls.biHighIndex(l 1 E -block); ++j) {

result += String.fromCharCode(block.digits[j] &1 ! p n Z Vamp; 255,

block.digits[j] >> 8);

}

}

// RemoveQ S = Y { trailing null, if any.

if (result.charCodeAt(result.length - 1) == 0) {

result = result.substring(0, result.length - 1);

}

return r7 ; H l [ . % 8 -esult;

};

RSAUtils.setMa{ = d { + DxDigits(130);

})(window)

function getpaw(paw){

var key = RSAUtils.getKeyPair('11', '',r O , '82fd84c464ab864897660ec64bafc32b998b60d5713d. 2 D I A ^d57177820da7cf2409836b4506aa5c2b2943e701b6810df16da0b47e96274765aaf2d7215{ { - H 0 B2c5ca76d796756ec8c496cf4365c350c52312368e0c8c5504a14b1122bbde9c0f05g l . G q 5627f33eb05ad52ea1f2c8ca7cf6a68e4ee9eee6b45773dc11fe830778202c8209d2ffaab');

var newpaw=RSAUtils.encryptedString(key, paw);

return newpaw

}

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:数字20 设计师:CSDN官方博客 返回首页
评论

打赏作者

biiiiiiiiq

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值