\r\n\r\n\r\n","import mod from \"-!../../node_modules/cache-loader/dist/cjs.js??ref--12-0!../../node_modules/thread-loader/dist/cjs.js!../../node_modules/babel-loader/lib/index.js!../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../node_modules/vue-loader/lib/index.js??vue-loader-options!./window.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../node_modules/cache-loader/dist/cjs.js??ref--12-0!../../node_modules/thread-loader/dist/cjs.js!../../node_modules/babel-loader/lib/index.js!../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../node_modules/vue-loader/lib/index.js??vue-loader-options!./window.vue?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./window.vue?vue&type=template&id=fce59d98&scoped=true&\"\nimport script from \"./window.vue?vue&type=script&lang=js&\"\nexport * from \"./window.vue?vue&type=script&lang=js&\"\nimport style0 from \"./window.vue?vue&type=style&index=0&id=fce59d98&scoped=true&lang=css&\"\n\n\n/* normalize component */\nimport normalizer from \"!../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n \"fce59d98\",\n null\n \n)\n\nexport default component.exports","let t = \"http://img.fengbolive.com/pic/avatar/{0}_{1}_200*200.jpg\"\r\nconst state = {\r\n anchorList: [],\r\n anchorInfoMap: {},\r\n}\r\nconst mutations = {\r\n FAMILY_UPDATA_ANCHOR_LIST(state, data) {\r\n if (null == data) {\r\n state.anchorList = [];\r\n return;\r\n }\r\n let lsSrc = data;\r\n let info, url = null;\r\n for (let i = 0; i < lsSrc.length; i++) {\r\n // console.log(\"FAMILY_UPDATA_ANCHOR_LIST\", lsSrc.length, lsSrc[i]);\r\n info = lsSrc[i];\r\n url = info.aurl;\r\n if (info.phid == 0) {\r\n info['img'] = \"\\\\\\\\static/face/default.png\";\r\n } else {\r\n info['img'] = t.format(info.id, info.phid);\r\n info['pnum'] = info.phid;\r\n info['uid'] = info.id;\r\n }\r\n info['name'] = decodeURI(info.name)\r\n if (url.indexOf('hdlws.sinashow.com') > 0) {\r\n //var state = 0;\r\n info['url'] = url.replace('hdlws.sinashow.com', 'hlsws.sinashow.com').replace('.flv', '/playlist.m3u8');\r\n } else if (url.indexOf('hdlnew.sinashow.com') > 0) {\r\n info['url'] = url.replace('hdlnew.sinashow.com', 'hlsws.sinashow.com').replace('.flv', '/playlist.m3u8');\r\n } else {\r\n //var state = 1;\r\n info['url'] = url.replace('hdlks.sinashow.com', 'hlsks.sinashow.com').replace('.flv', '/index.m3u8');\r\n }\r\n info.id = info.id.toString();\r\n state.anchorList.push(info);\r\n //将数据存入映射当中\r\n state.anchorInfoMap[info.id] = info\r\n }\r\n // console.log(\"FAMILY_UPDATA_ANCHOR_LIST state.anchorList\", state.anchorList);\r\n }\r\n}\r\n\r\nconst actions = {\r\n\r\n}\r\n\r\nconst getters = {\r\n getAnchorInfoByIDFromFamilyList: (state) => (id) => {\r\n let b = state.anchorInfoMap[id];\r\n if (b == null) {\r\n b = state.anchorList.find((e) => (e.id == id))\r\n }\r\n return b\r\n },\r\n getAnchorSeverInfoByIDFromFamilyList: (state) => (id) => {\r\n let anchorInfo = state.anchorInfoMap[id];\r\n if (!anchorInfo) {\r\n return null;\r\n }\r\n let sInfo = state.anchorInfo.ip;\r\n for (let index = 0; index < sInfo.length; index++) {\r\n const element = sInfo[index];\r\n if (element.isp == 3) {\r\n return sInfo[index];\r\n }\r\n\r\n }\r\n return sInfo[0];\r\n },\r\n}\r\n\r\nexport default {\r\n state,\r\n mutations,\r\n actions,\r\n getters\r\n}","// BigInt, a suite of routines for performing multiple-precision arithmetic in\r\n// JavaScript.\r\n//\r\n// Copyright 1998-2005 David Shapiro.\r\n//\r\n// You may use, re-use, abuse,\r\n// copy, and modify this code to your liking, but please keep this header.\r\n// Thanks!\r\n//\r\n// Dave Shapiro\r\n// dave@ohdave.com\r\n\r\n// IMPORTANT THING: Be sure to set maxDigits according to your precision\r\n// needs. Use the setMaxDigits() function to do this. See comments below.\r\n//\r\n// Tweaked by Ian Bunning\r\n// Alterations:\r\n// Fix bug in function biFromHex(s) to allow\r\n// parsing of strings of length != 0 (mod 4)\r\n\r\n// Changes made by Dave Shapiro as of 12/30/2004:\r\n//\r\n// The BigInt() constructor doesn't take a string anymore. If you want to\r\n// create a BigInt from a string, use biFromDecimal() for base-10\r\n// representations, biFromHex() for base-16 representations, or\r\n// biFromString() for base-2-to-36 representations.\r\n//\r\n// biFromArray() has been removed. Use biCopy() instead, passing a BigInt\r\n// instead of an array.\r\n//\r\n// The BigInt() constructor now only constructs a zeroed-out array.\r\n// Alternatively, if you pass , it won't construct any array. See the\r\n// biCopy() method for an example of this.\r\n//\r\n// Be sure to set maxDigits depending on your precision needs. The default\r\n// zeroed-out array ZERO_ARRAY is constructed inside the setMaxDigits()\r\n// function. So use this function to set the variable. DON'T JUST SET THE\r\n// VALUE. USE THE FUNCTION.\r\n//\r\n// ZERO_ARRAY exists to hopefully speed up construction of BigInts(). By\r\n// precalculating the zero array, we can just use slice(0) to make copies of\r\n// it. Presumably this calls faster native code, as opposed to setting the\r\n// elements one at a time. I have not done any timing tests to verify this\r\n// claim.\r\n\r\n// Max number = 10^16 - 2 = 9999999999999998;\r\n// 2^53 = 9007199254740992;\r\n\r\nvar biRadixBase = 2;\r\nvar biRadixBits = 16;\r\nvar bitsPerDigit = biRadixBits;\r\nvar biRadix = 1 << 16; // = 2^16 = 65536\r\nvar biHalfRadix = biRadix >>> 1;\r\nvar biRadixSquared = biRadix * biRadix;\r\nvar maxDigitVal = biRadix - 1;\r\nvar maxInteger = 9999999999999998; \r\n\r\n// maxDigits:\r\n// Change this to accommodate your largest number size. Use setMaxDigits()\r\n// to change it!\r\n//\r\n// In general, if you're working with numbers of size N bits, you'll need 2*N\r\n// bits of storage. Each digit holds 16 bits. So, a 1024-bit key will need\r\n//\r\n// 1024 * 2 / 16 = 128 digits of storage.\r\n//\r\n\r\nvar maxDigits;\r\nvar ZERO_ARRAY;\r\nvar bigZero, bigOne;\r\n\r\nexport function setMaxDigits(value)\r\n{\r\n\tmaxDigits = value;\r\n\tZERO_ARRAY = new Array(maxDigits);\r\n\tfor (var iza = 0; iza < ZERO_ARRAY.length; iza++) ZERO_ARRAY[iza] = 0;\r\n\tbigZero = new BigInt();\r\n\tbigOne = new BigInt();\r\n\tbigOne.digits[0] = 1;\r\n}\r\n\r\nsetMaxDigits(20);\r\n\r\n// The maximum number of digits in base 10 you can convert to an\r\n// integer without JavaScript throwing up on you.\r\nvar dpl10 = 15;\r\n// lr10 = 10 ^ dpl10\r\nvar lr10 = biFromNumber(1000000000000000);\r\n\r\nexport function BigInt(flag)\r\n{\r\n\tif (typeof flag == \"boolean\" && flag == true) {\r\n\t\tthis.digits = null;\r\n\t}\r\n\telse {\r\n\t\tthis.digits = ZERO_ARRAY.slice(0);\r\n\t}\r\n\tthis.isNeg = false;\r\n}\r\n\r\nexport function biFromDecimal(s)\r\n{\r\n\tvar isNeg = s.charAt(0) == '-';\r\n\tvar i = isNeg ? 1 : 0;\r\n\tvar result;\r\n\t// Skip leading zeros.\r\n\twhile (i < s.length && s.charAt(i) == '0') ++i;\r\n\tif (i == s.length) {\r\n\t\tresult = new BigInt();\r\n\t}\r\n\telse {\r\n\t\tvar digitCount = s.length - i;\r\n\t\tvar fgl = digitCount % dpl10;\r\n\t\tif (fgl == 0) fgl = dpl10;\r\n\t\tresult = biFromNumber(Number(s.substr(i, fgl)));\r\n\t\ti += fgl;\r\n\t\twhile (i < s.length) {\r\n\t\t\tresult = biAdd(biMultiply(result, lr10),\r\n\t\t\t biFromNumber(Number(s.substr(i, dpl10))));\r\n\t\t\ti += dpl10;\r\n\t\t}\r\n\t\tresult.isNeg = isNeg;\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nexport function biCopy(bi)\r\n{\r\n\tvar result = new BigInt(true);\r\n\tresult.digits = bi.digits.slice(0);\r\n\tresult.isNeg = bi.isNeg;\r\n\treturn result;\r\n}\r\n\r\nexport function biFromNumber(i)\r\n{\r\n\tvar result = new BigInt();\r\n\tresult.isNeg = i < 0;\r\n\ti = Math.abs(i);\r\n\tvar j = 0;\r\n\twhile (i > 0) {\r\n\t\tresult.digits[j++] = i & maxDigitVal;\r\n\t\ti >>= biRadixBits;\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nexport function reverseStr(s)\r\n{\r\n\tvar result = \"\";\r\n\tfor (var i = s.length - 1; i > -1; --i) {\r\n\t\tresult += s.charAt(i);\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nvar hexatrigesimalToChar = new Array(\r\n '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',\r\n 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',\r\n 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',\r\n 'u', 'v', 'w', 'x', 'y', 'z'\r\n);\r\n\r\nexport function biToString(x, radix)\r\n\t// 2 <= radix <= 36\r\n{\r\n\tvar b = new BigInt();\r\n\tb.digits[0] = radix;\r\n\tvar qr = biDivideModulo(x, b);\r\n\tvar result = hexatrigesimalToChar[qr[1].digits[0]];\r\n\twhile (biCompare(qr[0], bigZero) == 1) {\r\n\t\tqr = biDivideModulo(qr[0], b);\r\n\t\tdigit = qr[1].digits[0];\r\n\t\tresult += hexatrigesimalToChar[qr[1].digits[0]];\r\n\t}\r\n\treturn (x.isNeg ? \"-\" : \"\") + reverseStr(result);\r\n}\r\n\r\nexport function biToDecimal(x)\r\n{\r\n\tvar b = new BigInt();\r\n\tb.digits[0] = 10;\r\n\tvar qr = biDivideModulo(x, b);\r\n\tvar result = String(qr[1].digits[0]);\r\n\twhile (biCompare(qr[0], bigZero) == 1) {\r\n\t\tqr = biDivideModulo(qr[0], b);\r\n\t\tresult += String(qr[1].digits[0]);\r\n\t}\r\n\treturn (x.isNeg ? \"-\" : \"\") + reverseStr(result);\r\n}\r\n\r\nvar hexToChar = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9',\r\n 'a', 'b', 'c', 'd', 'e', 'f');\r\n\r\nexport function digitToHex(n)\r\n{\r\n\tvar mask = 0xf;\r\n\tvar result = \"\";\r\n\tfor (var i = 0; i < 4; ++i) {\r\n\t\tresult += hexToChar[n & mask];\r\n\t\tn >>>= 4;\r\n\t}\r\n\treturn reverseStr(result);\r\n}\r\n\r\nexport function biToHex(x)\r\n{\r\n\tvar result = \"\";\r\n\tvar n = biHighIndex(x);\r\n\tfor (var i = biHighIndex(x); i > -1; --i) {\r\n\t\tresult += digitToHex(x.digits[i]);\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nexport function charToHex(c)\r\n{\r\n\tvar ZERO = 48;\r\n\tvar NINE = ZERO + 9;\r\n\tvar littleA = 97;\r\n\tvar littleZ = littleA + 25;\r\n\tvar bigA = 65;\r\n\tvar bigZ = 65 + 25;\r\n\tvar result;\r\n\r\n\tif (c >= ZERO && c <= NINE) {\r\n\t\tresult = c - ZERO;\r\n\t} else if (c >= bigA && c <= bigZ) {\r\n\t\tresult = 10 + c - bigA;\r\n\t} else if (c >= littleA && c <= littleZ) {\r\n\t\tresult = 10 + c - littleA;\r\n\t} else {\r\n\t\tresult = 0;\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nexport function hexToDigit(s)\r\n{\r\n\tvar result = 0;\r\n\tvar sl = Math.min(s.length, 4);\r\n\tfor (var i = 0; i < sl; ++i) {\r\n\t\tresult <<= 4;\r\n\t\tresult |= charToHex(s.charCodeAt(i))\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nexport function biFromHex(s)\r\n{\r\n\tvar result = new BigInt();\r\n\tvar sl = s.length;\r\n\tfor (var i = sl, j = 0; i > 0; i -= 4, ++j) {\r\n\t\tresult.digits[j] = hexToDigit(s.substr(Math.max(i - 4, 0), Math.min(i, 4)));\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nexport function biFromString(s, radix)\r\n{\r\n\tvar isNeg = s.charAt(0) == '-';\r\n\tvar istop = isNeg ? 1 : 0;\r\n\tvar result = new BigInt();\r\n\tvar place = new BigInt();\r\n\tplace.digits[0] = 1; // radix^0\r\n\tfor (var i = s.length - 1; i >= istop; i--) {\r\n\t\tvar c = s.charCodeAt(i);\r\n\t\tvar digit = charToHex(c);\r\n\t\tvar biDigit = biMultiplyDigit(place, digit);\r\n\t\tresult = biAdd(result, biDigit);\r\n\t\tplace = biMultiplyDigit(place, radix);\r\n\t}\r\n\tresult.isNeg = isNeg;\r\n\treturn result;\r\n}\r\n\r\nexport function biToBytes(x)\r\n\t// Returns a string containing raw bytes.\r\n{\r\n\tvar result = \"\";\r\n\tfor (var i = biHighIndex(x); i > -1; --i) {\r\n\t\tresult += digitToBytes(x.digits[i]);\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nexport function digitToBytes(n)\r\n\t// Convert two-byte digit to string containing both bytes.\r\n{\r\n\tvar c1 = String.fromCharCode(n & 0xff);\r\n\tn >>>= 8;\r\n\tvar c2 = String.fromCharCode(n & 0xff);\r\n\treturn c2 + c1;\r\n}\r\n\r\nexport function biDump(b)\r\n{\r\n\treturn (b.isNeg ? \"-\" : \"\") + b.digits.join(\" \");\r\n}\r\n\r\nexport function biAdd(x, y)\r\n{\r\n\tvar result;\r\n\r\n\tif (x.isNeg != y.isNeg) {\r\n\t\ty.isNeg = !y.isNeg;\r\n\t\tresult = biSubtract(x, y);\r\n\t\ty.isNeg = !y.isNeg;\r\n\t}\r\n\telse {\r\n\t\tresult = new BigInt();\r\n\t\tvar c = 0;\r\n\t\tvar n;\r\n\t\tfor (var i = 0; i < x.digits.length; ++i) {\r\n\t\t\tn = x.digits[i] + y.digits[i] + c;\r\n\t\t\tresult.digits[i] = n & 0xffff;\r\n\t\t\tc = Number(n >= biRadix);\r\n\t\t}\r\n\t\tresult.isNeg = x.isNeg;\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nexport function biSubtract(x, y)\r\n{\r\n\tvar result;\r\n\tif (x.isNeg != y.isNeg) {\r\n\t\ty.isNeg = !y.isNeg;\r\n\t\tresult = biAdd(x, y);\r\n\t\ty.isNeg = !y.isNeg;\r\n\t} else {\r\n\t\tresult = new BigInt();\r\n\t\tvar n, c;\r\n\t\tc = 0;\r\n\t\tfor (var i = 0; i < x.digits.length; ++i) {\r\n\t\t\tn = x.digits[i] - y.digits[i] + c;\r\n\t\t\tresult.digits[i] = n & 0xffff;\r\n\t\t\t// Stupid non-conforming modulus operation.\r\n\t\t\tif (result.digits[i] < 0) result.digits[i] += biRadix;\r\n\t\t\tc = 0 - Number(n < 0);\r\n\t\t}\r\n\t\t// Fix up the negative sign, if any.\r\n\t\tif (c == -1) {\r\n\t\t\tc = 0;\r\n\t\t\tfor (var i = 0; i < x.digits.length; ++i) {\r\n\t\t\t\tn = 0 - result.digits[i] + c;\r\n\t\t\t\tresult.digits[i] = n & 0xffff;\r\n\t\t\t\t// Stupid non-conforming modulus operation.\r\n\t\t\t\tif (result.digits[i] < 0) result.digits[i] += biRadix;\r\n\t\t\t\tc = 0 - Number(n < 0);\r\n\t\t\t}\r\n\t\t\t// Result is opposite sign of arguments.\r\n\t\t\tresult.isNeg = !x.isNeg;\r\n\t\t} else {\r\n\t\t\t// Result is same sign.\r\n\t\t\tresult.isNeg = x.isNeg;\r\n\t\t}\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nexport function biHighIndex(x)\r\n{\r\n\tvar result = x.digits.length - 1;\r\n\twhile (result > 0 && x.digits[result] == 0) --result;\r\n\treturn result;\r\n}\r\n\r\nexport function biNumBits(x)\r\n{\r\n\tvar n = biHighIndex(x);\r\n\tvar d = x.digits[n];\r\n\tvar m = (n + 1) * bitsPerDigit;\r\n\tvar result;\r\n\tfor (result = m; result > m - bitsPerDigit; --result) {\r\n\t\tif ((d & 0x8000) != 0) break;\r\n\t\td <<= 1;\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nexport function biMultiply(x, y)\r\n{\r\n\tvar result = new BigInt();\r\n\tvar c;\r\n\tvar n = biHighIndex(x);\r\n\tvar t = biHighIndex(y);\r\n\tvar u, uv, k;\r\n\r\n\tfor (var i = 0; i <= t; ++i) {\r\n\t\tc = 0;\r\n\t\tk = i;\r\n\t\tfor (var j = 0; j <= n; ++j, ++k) {\r\n\t\t\tuv = result.digits[k] + x.digits[j] * y.digits[i] + c;\r\n\t\t\tresult.digits[k] = uv & maxDigitVal;\r\n\t\t\tc = uv >>> biRadixBits;\r\n\t\t}\r\n\t\tresult.digits[i + n + 1] = c;\r\n\t}\r\n\t// Someone give me a logical xor, please.\r\n\tresult.isNeg = x.isNeg != y.isNeg;\r\n\treturn result;\r\n}\r\n\r\nexport function biMultiplyDigit(x, y)\r\n{\r\n\tvar n, c, uv;\r\n\r\n\tvar result = new BigInt();\r\n\tn = biHighIndex(x);\r\n\tc = 0;\r\n\tfor (var j = 0; j <= n; ++j) {\r\n\t\tuv = result.digits[j] + x.digits[j] * y + c;\r\n\t\tresult.digits[j] = uv & maxDigitVal;\r\n\t\tc = uv >>> biRadixBits;\r\n\t}\r\n\tresult.digits[1 + n] = c;\r\n\treturn result;\r\n}\r\n\r\nexport function arrayCopy(src, srcStart, dest, destStart, n)\r\n{\r\n\tvar m = Math.min(srcStart + n, src.length);\r\n\tfor (var i = srcStart, j = destStart; i < m; ++i, ++j) {\r\n\t\tdest[j] = src[i];\r\n\t}\r\n}\r\n\r\nvar highBitMasks = new Array(0x0000, 0x8000, 0xC000, 0xE000, 0xF000, 0xF800,\r\n 0xFC00, 0xFE00, 0xFF00, 0xFF80, 0xFFC0, 0xFFE0,\r\n 0xFFF0, 0xFFF8, 0xFFFC, 0xFFFE, 0xFFFF);\r\n\r\nexport function biShiftLeft(x, n)\r\n{\r\n\tvar digitCount = Math.floor(n / bitsPerDigit);\r\n\tvar result = new BigInt();\r\n\tarrayCopy(x.digits, 0, result.digits, digitCount,\r\n\t result.digits.length - digitCount);\r\n\tvar bits = n % bitsPerDigit;\r\n\tvar rightBits = bitsPerDigit - bits;\r\n\tfor (var i = result.digits.length - 1, i1 = i - 1; i > 0; --i, --i1) {\r\n\t\tresult.digits[i] = ((result.digits[i] << bits) & maxDigitVal) |\r\n\t\t ((result.digits[i1] & highBitMasks[bits]) >>>\r\n\t\t (rightBits));\r\n\t}\r\n\tresult.digits[0] = ((result.digits[i] << bits) & maxDigitVal);\r\n\tresult.isNeg = x.isNeg;\r\n\treturn result;\r\n}\r\n\r\nvar lowBitMasks = new Array(0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F,\r\n 0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF,\r\n 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF);\r\n\r\nexport function biShiftRight(x, n)\r\n{\r\n\tvar digitCount = Math.floor(n / bitsPerDigit);\r\n\tvar result = new BigInt();\r\n\tarrayCopy(x.digits, digitCount, result.digits, 0,\r\n\t x.digits.length - digitCount);\r\n\tvar bits = n % bitsPerDigit;\r\n\tvar leftBits = bitsPerDigit - bits;\r\n\tfor (var i = 0, i1 = i + 1; i < result.digits.length - 1; ++i, ++i1) {\r\n\t\tresult.digits[i] = (result.digits[i] >>> bits) |\r\n\t\t ((result.digits[i1] & lowBitMasks[bits]) << leftBits);\r\n\t}\r\n\tresult.digits[result.digits.length - 1] >>>= bits;\r\n\tresult.isNeg = x.isNeg;\r\n\treturn result;\r\n}\r\n\r\nexport function biMultiplyByRadixPower(x, n)\r\n{\r\n\tvar result = new BigInt();\r\n\tarrayCopy(x.digits, 0, result.digits, n, result.digits.length - n);\r\n\treturn result;\r\n}\r\n\r\nexport function biDivideByRadixPower(x, n)\r\n{\r\n\tvar result = new BigInt();\r\n\tarrayCopy(x.digits, n, result.digits, 0, result.digits.length - n);\r\n\treturn result;\r\n}\r\n\r\nexport function biModuloByRadixPower(x, n)\r\n{\r\n\tvar result = new BigInt();\r\n\tarrayCopy(x.digits, 0, result.digits, 0, n);\r\n\treturn result;\r\n}\r\n\r\nexport function biCompare(x, y)\r\n{\r\n\tif (x.isNeg != y.isNeg) {\r\n\t\treturn 1 - 2 * Number(x.isNeg);\r\n\t}\r\n\tfor (var i = x.digits.length - 1; i >= 0; --i) {\r\n\t\tif (x.digits[i] != y.digits[i]) {\r\n\t\t\tif (x.isNeg) {\r\n\t\t\t\treturn 1 - 2 * Number(x.digits[i] > y.digits[i]);\r\n\t\t\t} else {\r\n\t\t\t\treturn 1 - 2 * Number(x.digits[i] < y.digits[i]);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\nexport function biDivideModulo(x, y)\r\n{\r\n\tvar nb = biNumBits(x);\r\n\tvar tb = biNumBits(y);\r\n\tvar origYIsNeg = y.isNeg;\r\n\tvar q, r;\r\n\tif (nb < tb) {\r\n\t\t// |x| < |y|\r\n\t\tif (x.isNeg) {\r\n\t\t\tq = biCopy(bigOne);\r\n\t\t\tq.isNeg = !y.isNeg;\r\n\t\t\tx.isNeg = false;\r\n\t\t\ty.isNeg = false;\r\n\t\t\tr = biSubtract(y, x);\r\n\t\t\t// Restore signs, 'cause they're references.\r\n\t\t\tx.isNeg = true;\r\n\t\t\ty.isNeg = origYIsNeg;\r\n\t\t} else {\r\n\t\t\tq = new BigInt();\r\n\t\t\tr = biCopy(x);\r\n\t\t}\r\n\t\treturn new Array(q, r);\r\n\t}\r\n\r\n\tq = new BigInt();\r\n\tr = x;\r\n\r\n\t// Normalize Y.\r\n\tvar t = Math.ceil(tb / bitsPerDigit) - 1;\r\n\tvar lambda = 0;\r\n\twhile (y.digits[t] < biHalfRadix) {\r\n\t\ty = biShiftLeft(y, 1);\r\n\t\t++lambda;\r\n\t\t++tb;\r\n\t\tt = Math.ceil(tb / bitsPerDigit) - 1;\r\n\t}\r\n\t// Shift r over to keep the quotient constant. We'll shift the\r\n\t// remainder back at the end.\r\n\tr = biShiftLeft(r, lambda);\r\n\tnb += lambda; // Update the bit count for x.\r\n\tvar n = Math.ceil(nb / bitsPerDigit) - 1;\r\n\r\n\tvar b = biMultiplyByRadixPower(y, n - t);\r\n\twhile (biCompare(r, b) != -1) {\r\n\t\t++q.digits[n - t];\r\n\t\tr = biSubtract(r, b);\r\n\t}\r\n\tfor (var i = n; i > t; --i) {\r\n var ri = (i >= r.digits.length) ? 0 : r.digits[i];\r\n var ri1 = (i - 1 >= r.digits.length) ? 0 : r.digits[i - 1];\r\n var ri2 = (i - 2 >= r.digits.length) ? 0 : r.digits[i - 2];\r\n var yt = (t >= y.digits.length) ? 0 : y.digits[t];\r\n var yt1 = (t - 1 >= y.digits.length) ? 0 : y.digits[t - 1];\r\n\t\tif (ri == yt) {\r\n\t\t\tq.digits[i - t - 1] = maxDigitVal;\r\n\t\t} else {\r\n\t\t\tq.digits[i - t - 1] = Math.floor((ri * biRadix + ri1) / yt);\r\n\t\t}\r\n\r\n\t\tvar c1 = q.digits[i - t - 1] * ((yt * biRadix) + yt1);\r\n\t\tvar c2 = (ri * biRadixSquared) + ((ri1 * biRadix) + ri2);\r\n\t\twhile (c1 > c2) {\r\n\t\t\t--q.digits[i - t - 1];\r\n\t\t\tc1 = q.digits[i - t - 1] * ((yt * biRadix) | yt1);\r\n\t\t\tc2 = (ri * biRadix * biRadix) + ((ri1 * biRadix) + ri2);\r\n\t\t}\r\n\r\n\t\tb = biMultiplyByRadixPower(y, i - t - 1);\r\n\t\tr = biSubtract(r, biMultiplyDigit(b, q.digits[i - t - 1]));\r\n\t\tif (r.isNeg) {\r\n\t\t\tr = biAdd(r, b);\r\n\t\t\t--q.digits[i - t - 1];\r\n\t\t}\r\n\t}\r\n\tr = biShiftRight(r, lambda);\r\n\t// Fiddle with the signs and stuff to make sure that 0 <= r < y.\r\n\tq.isNeg = x.isNeg != origYIsNeg;\r\n\tif (x.isNeg) {\r\n\t\tif (origYIsNeg) {\r\n\t\t\tq = biAdd(q, bigOne);\r\n\t\t} else {\r\n\t\t\tq = biSubtract(q, bigOne);\r\n\t\t}\r\n\t\ty = biShiftRight(y, lambda);\r\n\t\tr = biSubtract(y, r);\r\n\t}\r\n\t// Check for the unbelievably stupid degenerate case of r == -0.\r\n\tif (r.digits[0] == 0 && biHighIndex(r) == 0) r.isNeg = false;\r\n\r\n\treturn new Array(q, r);\r\n}\r\n\r\nexport function biDivide(x, y)\r\n{\r\n\treturn biDivideModulo(x, y)[0];\r\n}\r\n\r\nexport function biModulo(x, y)\r\n{\r\n\treturn biDivideModulo(x, y)[1];\r\n}\r\n\r\nexport function biMultiplyMod(x, y, m)\r\n{\r\n\treturn biModulo(biMultiply(x, y), m);\r\n}\r\n\r\nexport function biPow(x, y)\r\n{\r\n\tvar result = bigOne;\r\n\tvar a = x;\r\n\twhile (true) {\r\n\t\tif ((y & 1) != 0) result = biMultiply(result, a);\r\n\t\ty >>= 1;\r\n\t\tif (y == 0) break;\r\n\t\ta = biMultiply(a, a);\r\n\t}\r\n\treturn result;\r\n}\r\n\r\nexport function biPowMod(x, y, m)\r\n{\r\n\tvar result = bigOne;\r\n\tvar a = x;\r\n\tvar k = y;\r\n\twhile (true) {\r\n\t\tif ((k.digits[0] & 1) != 0) result = biMultiplyMod(result, a, m);\r\n\t\tk = biShiftRight(k, 1);\r\n\t\tif (k.digits[0] == 0 && biHighIndex(k) == 0) break;\r\n\t\ta = biMultiplyMod(a, a, m);\r\n\t}\r\n\treturn result;\r\n}\r\n\r\n","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{attrs:{\"id\":\"app\"}},[_c('router-view'),_c('loginReg'),_c('windowBox')],1)}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('transition',{attrs:{\"name\":\"fade\"}},[(_vm.showBool)?_c('div',{staticClass:\"loginReg\"},[_c('div',{directives:[{name:\"show\",rawName:\"v-show\",value:(!_vm.findPwd.open),expression:\"!findPwd.open\"}],staticClass:\"loginRegBox\"},[_c('div',{staticClass:\"loginRegTitle\"},[_c('div',{staticClass:\"btnBox\"},[_c('div',{class:_vm.activeType==1?'loginchangeBtn active':'loginchangeBtn',on:{\"click\":function($event){return _vm.tab(1)}}},[_vm._v(\"登录\")]),_c('div',{class:_vm.activeType==2?'regChangeBtn active':'regChangeBtn',on:{\"click\":function($event){return _vm.tab(2)}}},[_vm._v(\"注册\")])]),_c('div',{directives:[{name:\"show\",rawName:\"v-show\",value:(_vm.showCloseBool),expression:\"showCloseBool\"}],staticClass:\"closeBtn\",on:{\"click\":_vm.showLoginReg}})]),_c('div',{staticClass:\"loginRegCon\"},[_c('div',{directives:[{name:\"show\",rawName:\"v-show\",value:(_vm.activeType==1),expression:\"activeType==1\"}],staticClass:\"loginRegConL\"},[_c('div',{staticClass:\"loginRegConTitle\"},[_vm._v(\"登录\")]),_c('div',{staticClass:\"accountNum inputBox\"},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.login.phone),expression:\"login.phone\"}],attrs:{\"type\":\"tel\",\"maxlength\":\"11\",\"placeholder\":\"输入手机号\"},domProps:{\"value\":(_vm.login.phone)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.login, \"phone\", $event.target.value)}}})]),_c('div',{staticClass:\"password inputBox\"},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.login.pwd),expression:\"login.pwd\"}],attrs:{\"type\":\"password\",\"placeholder\":\"输入密码\"},domProps:{\"value\":(_vm.login.pwd)},on:{\"keyup\":function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,\"enter\",13,$event.key,\"Enter\")){ return null; }return _vm.loginClick($event)},\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.login, \"pwd\", $event.target.value)}}})]),_c('div',{staticClass:\"autoLogin\"},[_c('span',{class:_vm.auto_login?'changeIcon active':'changeIcon',on:{\"click\":_vm.autoLogin}}),_vm._v(\"\\n 一周内自动登录\\n \")]),_c('div',{staticClass:\"loginBtn loginRegBtn\",on:{\"click\":_vm.loginClick}},[_vm._v(\"登录\")]),_c('div',{staticClass:\"findPassWord\",on:{\"click\":function($event){return _vm.showFindPwd(true)}}},[_vm._v(\"找回密码\")])]),_c('div',{directives:[{name:\"show\",rawName:\"v-show\",value:(_vm.activeType==2),expression:\"activeType==2\"}],staticClass:\"loginRegConL\"},[_c('div',{staticClass:\"loginRegConTitle\"},[_vm._v(\"注册\")]),_c('div',{staticClass:\"accountNum inputBox\"},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.reg.phone),expression:\"reg.phone\"}],attrs:{\"type\":\"tel\",\"maxlength\":\"11\",\"placeholder\":\"输入手机号\"},domProps:{\"value\":(_vm.reg.phone)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.reg, \"phone\", $event.target.value)}}})]),_c('div',{staticClass:\"password inputBox halfBox\"},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.reg.code),expression:\"reg.code\"}],attrs:{\"type\":\"text\",\"placeholder\":\"输入验证码\"},domProps:{\"value\":(_vm.reg.code)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.reg, \"code\", $event.target.value)}}}),_c('span',{class:_vm.codeMsg=='获取验证码'?'purpleBtn':'garyBtn',on:{\"click\":_vm.getCode}},[_vm._v(_vm._s(_vm.codeMsg))])]),_c('div',{staticClass:\"password inputBox\"},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.reg.pwd),expression:\"reg.pwd\"}],attrs:{\"type\":\"password\",\"placeholder\":\"输入8-16位密码\"},domProps:{\"value\":(_vm.reg.pwd)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.reg, \"pwd\", $event.target.value)}}})]),_c('div',{staticClass:\"password inputBox\"},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.reg.repwd),expression:\"reg.repwd\"}],attrs:{\"type\":\"password\",\"placeholder\":\"再次输入密码\"},domProps:{\"value\":(_vm.reg.repwd)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.reg, \"repwd\", $event.target.value)}}})]),_c('div',{staticClass:\"loginBtn loginRegBtn regbutton\",class:_vm.agree_protocol?'':'disable',on:{\"click\":_vm.register}},[_vm._v(\"立即注册\")]),_c('div',{staticClass:\"autoLogin\"},[_c('span',{class:_vm.agree_protocol?'changeIcon active':'changeIcon',on:{\"click\":_vm.onAccept}}),_vm._v(\"\\n 同意\"),_c('a',{staticStyle:{\"color\":\"#7c46e8\"},attrs:{\"target\":\"_blank\",\"href\":\"/provision\"}},[_vm._v(\"《注册协议》\")]),_vm._v(\" \\n 和\"),_c('a',{staticStyle:{\"color\":\"#7c46e8\"},attrs:{\"target\":\"_blank\",\"href\":\"/policy\"}},[_vm._v(\"《隐私政策》\")])])]),_c('div',{staticClass:\"line\"}),_c('div',{staticClass:\"loginRegConR\"},[_c('div',{staticClass:\"loginRegConTitle\"},[_vm._v(\"第三方直接登录\")]),_c('div',{staticClass:\"btnList\"},[_c('div',{staticClass:\"loginThreeBtn\",on:{\"click\":function($event){return _vm.toLogin('qq',1)}}},[_vm._v(\"QQ账号登录\")]),_c('div',{staticClass:\"loginThreeBtn\",on:{\"click\":function($event){return _vm.toLogin('show',4)}}},[_vm._v(\"平台账号登录\")])]),_c('div',{staticClass:\"useThreeLoginExplain\"},[_vm._v(\"使用即为同意 \"),_c('a',{staticStyle:{\"color\":\"#7c46e8\"},attrs:{\"target\":\"_blank\",\"href\":\"/provision\"}},[_vm._v(\"《注册协议》\")]),_vm._v(\" 和\"),_c('a',{staticStyle:{\"color\":\"#7c46e8\"},attrs:{\"target\":\"_blank\",\"href\":\"/policy\"}},[_vm._v(\"《隐私政策》\")])])])])]),_c('div',{directives:[{name:\"show\",rawName:\"v-show\",value:(_vm.findPwd.open),expression:\"findPwd.open\"}],staticClass:\"findPwdBox\"},[_c('div',{staticClass:\"title\"},[_vm._v(\"找回密码\")]),_c('div',{staticClass:\"inputBoxR\"},[_c('div',{staticClass:\"contentTitle\"},[_vm._v(\"手机号:\")]),_c('div',{staticClass:\"inputBox\"},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.findPwd.phone),expression:\"findPwd.phone\"}],attrs:{\"type\":\"text\",\"placeholder\":\"请输入手机号码\",\"maxlength\":\"11\"},domProps:{\"value\":(_vm.findPwd.phone)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.findPwd, \"phone\", $event.target.value)}}})])]),_c('div',{staticClass:\"inputBoxR\"},[_c('div',{staticClass:\"contentTitle\"},[_vm._v(\"验证码:\")]),_c('div',{staticClass:\"inputBox\"},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.findPwd.code),expression:\"findPwd.code\"}],attrs:{\"type\":\"text\",\"placeholder\":\"请输入验证码\"},domProps:{\"value\":(_vm.findPwd.code)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.findPwd, \"code\", $event.target.value)}}}),_c('span',{class:_vm.findPwd.codeMsg=='获取验证码'?'purpleBtn':'garyBtn',on:{\"click\":_vm.pwdCode}},[_vm._v(_vm._s(_vm.findPwd.codeMsg))])])]),_c('div',{staticClass:\"inputBoxR\"},[_c('div',{staticClass:\"contentTitle\"},[_vm._v(\"新密码:\")]),_c('div',{staticClass:\"inputBox\"},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.findPwd.pwd),expression:\"findPwd.pwd\"}],attrs:{\"type\":\"password\",\"placeholder\":\"请输入密码\"},domProps:{\"value\":(_vm.findPwd.pwd)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.findPwd, \"pwd\", $event.target.value)}}})])]),_c('div',{staticClass:\"inputBoxR confirmPWd\"},[_c('div',{staticClass:\"contentTitle\"},[_vm._v(\"确认密码:\")]),_c('div',{staticClass:\"inputBox\"},[_c('input',{directives:[{name:\"model\",rawName:\"v-model\",value:(_vm.findPwd.repwd),expression:\"findPwd.repwd\"}],attrs:{\"type\":\"password\",\"placeholder\":\"请再次输入密码\"},domProps:{\"value\":(_vm.findPwd.repwd)},on:{\"input\":function($event){if($event.target.composing){ return; }_vm.$set(_vm.findPwd, \"repwd\", $event.target.value)}}})])]),_c('div',{staticClass:\"buttonBox\"},[_c('button',{staticClass:\"purpleBtn\",on:{\"click\":_vm.findPwdClick}},[_vm._v(\"确认\")]),_c('button',{staticClass:\"purpleBtn\",on:{\"click\":function($event){return _vm.showFindPwd(false)}}},[_vm._v(\"取消\")])])])]):_vm._e()])}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","// BarrettMu, a class for performing Barrett modular reduction computations in\r\n// JavaScript.\r\n//\r\n// Requires BigInt.js.\r\n//\r\n// Copyright 2004-2005 David Shapiro.\r\n//\r\n// You may use, re-use, abuse, copy, and modify this code to your liking, but\r\n// please keep this header.\r\n//\r\n// Thanks!\r\n// \r\n// Dave Shapiro\r\n// dave@ohdave.com \r\nimport {biCopy, biHighIndex, biDivide, biDivideByRadixPower, biMultiply, biModuloByRadixPower, biSubtract, biAdd, biCompare, biShiftRight, BigInt }from './BigInt.js'\r\nexport function BarrettMu(m)\r\n{\r\n\tthis.modulus = biCopy(m);\r\n\tthis.k = biHighIndex(this.modulus) + 1;\r\n\tvar b2k = new BigInt();\r\n\tb2k.digits[2 * this.k] = 1; // b2k = b^(2k)\r\n\tthis.mu = biDivide(b2k, this.modulus);\r\n\tthis.bkplus1 = new BigInt();\r\n\tthis.bkplus1.digits[this.k + 1] = 1; // bkplus1 = b^(k+1)\r\n\tthis.modulo = BarrettMu_modulo;\r\n\tthis.multiplyMod = BarrettMu_multiplyMod;\r\n\tthis.powMod = BarrettMu_powMod;\r\n}\r\n\r\nexport function BarrettMu_modulo(x)\r\n{\r\n\tvar q1 = biDivideByRadixPower(x, this.k - 1);\r\n\tvar q2 = biMultiply(q1, this.mu);\r\n\tvar q3 = biDivideByRadixPower(q2, this.k + 1);\r\n\tvar r1 = biModuloByRadixPower(x, this.k + 1);\r\n\tvar r2term = biMultiply(q3, this.modulus);\r\n\tvar r2 = biModuloByRadixPower(r2term, this.k + 1);\r\n\tvar r = biSubtract(r1, r2);\r\n\tif (r.isNeg) {\r\n\t\tr = biAdd(r, this.bkplus1);\r\n\t}\r\n\tvar rgtem = biCompare(r, this.modulus) >= 0;\r\n\twhile (rgtem) {\r\n\t\tr = biSubtract(r, this.modulus);\r\n\t\trgtem = biCompare(r, this.modulus) >= 0;\r\n\t}\r\n\treturn r;\r\n}\r\n\r\nexport function BarrettMu_multiplyMod(x, y)\r\n{\r\n\t/*\r\n\tx = this.modulo(x);\r\n\ty = this.modulo(y);\r\n\t*/\r\n\tvar xy = biMultiply(x, y);\r\n\treturn this.modulo(xy);\r\n}\r\n\r\nexport function BarrettMu_powMod(x, y)\r\n{\r\n\tvar result = new BigInt();\r\n\tresult.digits[0] = 1;\r\n\tvar a = x;\r\n\tvar k = y;\r\n\twhile (true) {\r\n\t\tif ((k.digits[0] & 1) != 0) result = this.multiplyMod(result, a);\r\n\t\tk = biShiftRight(k, 1);\r\n\t\tif (k.digits[0] == 0 && biHighIndex(k) == 0) break;\r\n\t\ta = this.multiplyMod(a, a);\r\n\t}\r\n\treturn result;\r\n}\r\n\r\n","/*\r\n * Copyright (c) 2015 Eric Wilde.\r\n * Copyright 1998-2015 David Shapiro.\r\n * \r\n * RSA.js is a suite of routines for performing RSA public-key computations\r\n * in JavaScript. The cryptographic functions herein are used for encoding\r\n * and decoding strings to be sent over unsecure channels.\r\n *\r\n * To use these routines, a pair of public/private keys is created through a\r\n * number of means (OpenSSL tools on Linux/Unix, Dave Shapiro's\r\n * RSAKeyGenerator program on Windows). These keys are passed to RSAKeyPair\r\n * as hexadecimal strings to create an encryption key object. This key object\r\n * is then used with encryptedString to encrypt blocks of plaintext using the\r\n * public key. The resulting cyphertext blocks can be decrypted with\r\n * decryptedString.\r\n *\r\n * Note that the cryptographic functions herein are complementary to those\r\n * found in CryptoFuncs.php and CryptoFuncs.pm. Hence, encrypted messages may\r\n * be sent between programs written in any of those languages. The most\r\n * useful, of course is to send messages encrypted by a Web page using RSA.js\r\n * to a PHP or Perl script running on a Web servitron.\r\n *\r\n * Also, the optional padding flag may be specified on the call to\r\n * encryptedString, in which case blocks of cyphertext that are compatible\r\n * with real crypto libraries such as OpenSSL or Microsoft will be created.\r\n * These blocks of cyphertext can then be sent to Web servitron that uses one\r\n * of these crypto libraries for decryption. This allows messages encrypted\r\n * with longer keys to be decrypted quickly on the Web server as well as\r\n * making for more secure communications when a padding algorithm such as\r\n * PKCS1v1.5 is used.\r\n *\r\n * These routines require BigInt.js and Barrett.js.\r\n */\r\n\r\n/*****************************************************************************/\r\n\r\n/*\r\n * Modifications\r\n * -------------\r\n *\r\n * 2014 Jan 11 E. Wilde Add optional padding flag to encryptedString\r\n * for compatibility with real crypto libraries\r\n * such as OpenSSL or Microsoft. Add PKCS1v1.5\r\n * padding.\r\n *\r\n * 2015 Jan 5 D. Shapiro Add optional encoding flag for encryptedString\r\n * and encapsulate padding and encoding constants\r\n * in RSAAPP object.\r\n *\r\n * Original Code\r\n * -------------\r\n *\r\n * Copyright 1998-2005 David Shapiro.\r\n *\r\n * You may use, re-use, abuse, copy, and modify this code to your liking, but\r\n * please keep this header.\r\n *\r\n * Thanks!\r\n * \r\n * Dave Shapiro\r\n * dave@ohdave.com\r\n */\r\n\r\n/*****************************************************************************/\r\nimport * as bigint from './BigInt.js'\r\nimport {BarrettMu} from './Barrett.js'\r\nexport var RSAAPP = {};\r\n\r\nRSAAPP.NoPadding = \"NoPadding\";\r\nRSAAPP.PKCS1Padding = \"PKCS1Padding\";\r\nRSAAPP.RawEncoding = \"RawEncoding\";\r\nRSAAPP.NumericEncoding = \"NumericEncoding\"\r\n\r\n/*****************************************************************************/\r\nexport class RSAKeyPair {\r\n constructor(encryptionExponent, decryptionExponent, modulus, keylen) {\r\n /*\r\n * Convert from hexadecimal and save the encryption/decryption exponents and\r\n * modulus as big integers in the key object.\r\n */\r\n this.e = bigint.biFromHex(encryptionExponent);\r\n this.d = bigint.biFromHex(decryptionExponent);\r\n this.m = bigint.biFromHex(modulus);\r\n /*\r\n * Using big integers, we can represent two bytes per element in the big\r\n * integer array, so we calculate the chunk size as:\r\n *\r\n * chunkSize = 2 * (number of digits in modulus - 1)\r\n *\r\n * Since biHighIndex returns the high index, not the number of digits, the\r\n * number 1 has already been subtracted from its answer.\r\n *\r\n * However, having said all this, \"User Knows Best\". If our caller passes us\r\n * a key length (in bits), we'll treat it as gospel truth.\r\n */\r\n if (typeof (keylen) != 'number') {\r\n this.chunkSize = 2 * bigint.biHighIndex(this.m);\r\n }\r\n else {\r\n this.chunkSize = keylen / 8;\r\n }\r\n this.radix = 16;\r\n /*\r\n * Precalculate the stuff used for Barrett modular reductions.\r\n */\r\n this.barrett = new BarrettMu(this.m);\r\n }\r\n}\r\n\r\n/*****************************************************************************/\r\n\r\nexport function encryptedString(key, s, pad, encoding)\r\n/*\r\n * key The previously-built RSA key whose\r\n * public key component is to be used to\r\n * encrypt the plaintext string.\r\n *\r\n * s The plaintext string that is to be\r\n * encrypted, using the RSA assymmetric\r\n * encryption method.\r\n *\r\n * pad The optional padding method to use\r\n * when extending the plaintext to the\r\n * full chunk size required by the RSA\r\n * algorithm. To maintain compatibility\r\n * with other crypto libraries, the\r\n * padding method is described by a\r\n * string. The default, if not\r\n * specified is \"OHDave\". Here are the\r\n * choices:\r\n *\r\n * OHDave - this is the original\r\n * padding method employed by Dave\r\n * Shapiro and Rob Saunders. If\r\n * this method is chosen, the\r\n * plaintext can be of any length.\r\n * It will be padded to the correct\r\n * length with zeros and then broken\r\n * up into chunks of the correct\r\n * length before being encrypted.\r\n * The resultant cyphertext blocks\r\n * will be separated by blanks.\r\n *\r\n * Note that the original code by\r\n * Dave Shapiro reverses the byte\r\n * order to little-endian, as the\r\n * plaintext is encrypted. If\r\n * either these JavaScript routines\r\n * or one of the complementary\r\n * PHP/Perl routines derived from\r\n * this code is used for decryption,\r\n * the byte order will be reversed\r\n * again upon decryption so as to\r\n * come out correctly.\r\n * \r\n * Also note that this padding\r\n * method is claimed to be less\r\n * secure than PKCS1Padding.\r\n *\r\n * NoPadding - this method truncates\r\n * the plaintext to the length of\r\n * the RSA key, if it is longer. If\r\n * its length is shorter, it is\r\n * padded with zeros. In either\r\n * case, the plaintext string is\r\n * reversed to preserve big-endian\r\n * order before it is encrypted to\r\n * maintain compatibility with real\r\n * crypto libraries such as OpenSSL\r\n * or Microsoft. When the\r\n * cyphertext is to be decrypted\r\n * by a crypto library, the\r\n * library routine's RSAAPP.NoPadding\r\n * flag, or its equivalent, should\r\n * be used.\r\n *\r\n * Note that this padding method is\r\n * claimed to be less secure than\r\n * PKCS1Padding.\r\n *\r\n * PKCS1Padding - the PKCS1v1.5\r\n * padding method (as described in\r\n * RFC 2313) is employed to pad the\r\n * plaintext string. The plaintext\r\n * string must be no longer than the\r\n * length of the RSA key minus 11,\r\n * since PKCS1v1.5 requires 3 bytes\r\n * of overhead and specifies a\r\n * minimum pad of 8 bytes. The\r\n * plaintext string is padded with\r\n * randomly-generated bytes and then\r\n * its order is reversed to preserve\r\n * big-endian order before it is\r\n * encrypted to maintain\r\n * compatibility with real crypto\r\n * libraries such as OpenSSL or\r\n * Microsoft. When the cyphertext\r\n * is to be decrypted by a crypto\r\n * library, the library routine's\r\n * RSAAPP.PKCS1Padding flag, or its\r\n * equivalent, should be used.\r\n *\r\n * encoding The optional encoding scheme to use\r\n * for the return value. If ommitted,\r\n * numeric encoding will be used.\r\n *\r\n * RawEncoding - The return value\r\n * is given as its raw value.\r\n * This is the easiest method when\r\n * interoperating with server-side\r\n * OpenSSL, as no additional conversion\r\n * is required. Use the constant\r\n * RSAAPP.RawEncoding for this option.\r\n *\r\n * NumericEncoding - The return value\r\n * is given as a number in hexadecimal.\r\n * Perhaps useful for debugging, but\r\n * will need to be translated back to\r\n * its raw equivalent (e.g. using\r\n * PHP's hex2bin) before using with\r\n * OpenSSL. Use the constant\r\n * RSAAPP.NumericEncoding for this option.\r\n *\r\n * returns The cyphertext block that results\r\n * from encrypting the plaintext string\r\n * s with the RSA key.\r\n *\r\n * This routine accepts a plaintext string that is to be encrypted with the\r\n * public key component of the previously-built RSA key using the RSA\r\n * assymmetric encryption method. Before it is encrypted, the plaintext\r\n * string is padded to the same length as the encryption key for proper\r\n * encryption.\r\n *\r\n * Depending on the padding method chosen, an optional header with block type\r\n * is prepended, the plaintext is padded using zeros or randomly-generated\r\n * bytes, and then the plaintext is possibly broken up into chunks.\r\n *\r\n * Note that, for padding with zeros, this routine was altered by Rob Saunders\r\n * (rob@robsaunders.net). The new routine pads the string after it has been\r\n * converted to an array. This fixes an incompatibility with Flash MX's\r\n * ActionScript.\r\n *\r\n * The various padding schemes employed by this routine, and as presented to\r\n * RSA for encryption, are shown below. Note that the RSA encryption done\r\n * herein reverses the byte order as encryption is done:\r\n *\r\n * Plaintext In\r\n * ------------\r\n *\r\n * d5 d4 d3 d2 d1 d0\r\n *\r\n * OHDave\r\n * ------\r\n *\r\n * d5 d4 d3 d2 d1 d0 00 00 00 /.../ 00 00 00 00 00 00 00 00\r\n *\r\n * NoPadding\r\n * ---------\r\n *\r\n * 00 00 00 00 00 00 00 00 00 /.../ 00 00 d0 d1 d2 d3 d4 d5\r\n *\r\n * PKCS1Padding\r\n * ------------\r\n *\r\n * d0 d1 d2 d3 d4 d5 00 p0 p1 /.../ p2 p3 p4 p5 p6 p7 02 00\r\n * \\------------ ------------/\r\n * \\/\r\n * Minimum 8 bytes pad length\r\n */\r\n{\r\n var a = new Array(); // The usual Alice and Bob stuff\r\n var sl = s.length; // Plaintext string length\r\n var i, j, k; // The usual Fortran index stuff\r\n var padtype; // Type of padding to do\r\n var encodingtype; // Type of output encoding\r\n var rpad; // Random pad\r\n var al; // Array length\r\n var result = \"\"; // Cypthertext result\r\n var block; // Big integer block to encrypt\r\n var crypt; // Big integer result\r\n var text; // Text result\r\n /*\r\n * Figure out the padding type.\r\n */\r\n if (typeof (pad) == 'string') {\r\n if (pad == RSAAPP.NoPadding) {\r\n padtype = 1;\r\n } else if (pad == RSAAPP.PKCS1Padding) {\r\n padtype = 2;\r\n } else {\r\n padtype = 0;\r\n }\r\n } else {\r\n padtype = 0;\r\n }\r\n /*\r\n * Determine encoding type.\r\n */\r\n if (typeof (encoding) == 'string' && encoding == RSAAPP.RawEncoding) {\r\n encodingtype = 1;\r\n } else {\r\n encodingtype = 0;\r\n }\r\n\r\n /*\r\n * If we're not using Dave's padding method, we need to truncate long\r\n * plaintext blocks to the correct length for the padding method used:\r\n *\r\n * NoPadding - key length\r\n * PKCS1Padding - key length - 11\r\n */\r\n if (padtype == 1) {\r\n if (sl > key.chunkSize) {\r\n sl = key.chunkSize;\r\n }\r\n } else if (padtype == 2) {\r\n if (sl > (key.chunkSize - 11)) {\r\n sl = key.chunkSize - 11;\r\n }\r\n }\r\n /*\r\n * Convert the plaintext string to an array of characters so that we can work\r\n * with individual characters.\r\n *\r\n * Note that, if we're talking to a real crypto library at the other end, we\r\n * reverse the plaintext order to preserve big-endian order.\r\n */\r\n i = 0;\r\n\r\n if (padtype == 2) {\r\n j = sl - 1;\r\n } else {\r\n j = key.chunkSize - 1;\r\n }\r\n\r\n while (i < sl) {\r\n if (padtype) {\r\n a[j] = s.charCodeAt(i);\r\n } else {\r\n a[i] = s.charCodeAt(i);\r\n }\r\n\r\n i++;\r\n j--;\r\n }\r\n /*\r\n * Now is the time to add the padding.\r\n *\r\n * If we're doing PKCS1v1.5 padding, we pick up padding where we left off and\r\n * pad the remainder of the block. Otherwise, we pad at the front of the\r\n * block. This gives us the correct padding for big-endian blocks.\r\n *\r\n * The padding is either a zero byte or a randomly-generated non-zero byte.\r\n */\r\n if (padtype == 1) {\r\n i = 0;\r\n }\r\n\r\n j = key.chunkSize - (sl % key.chunkSize);\r\n\r\n while (j > 0) {\r\n if (padtype == 2) {\r\n rpad = Math.floor(Math.random() * 256);\r\n\r\n while (!rpad) {\r\n rpad = Math.floor(Math.random() * 256);\r\n }\r\n\r\n a[i] = rpad;\r\n } else {\r\n a[i] = 0;\r\n }\r\n\r\n i++;\r\n j--;\r\n }\r\n /*\r\n * For PKCS1v1.5 padding, we need to fill in the block header.\r\n *\r\n * According to RFC 2313, a block type, a padding string, and the data shall\r\n * be formatted into the encryption block:\r\n *\r\n * EncrBlock = 00 || BlockType || PadString || 00 || Data\r\n *\r\n * The block type shall be a single octet indicating the structure of the\r\n * encryption block. For this version of the document it shall have value 00,\r\n * 01, or 02. For a private-key operation, the block type shall be 00 or 01.\r\n * For a public-key operation, it shall be 02.\r\n *\r\n * The padding string shall consist of enough octets to pad the encryption\r\n * block to the length of the encryption key. For block type 00, the octets\r\n * shall have value 00; for block type 01, they shall have value FF; and for\r\n * block type 02, they shall be pseudorandomly generated and nonzero.\r\n *\r\n * Note that in a previous step, we wrote padding bytes into the first three\r\n * bytes of the encryption block because it was simpler to do so. We now\r\n * overwrite them.\r\n */\r\n if (padtype == 2) {\r\n a[sl] = 0;\r\n a[key.chunkSize - 2] = 2;\r\n a[key.chunkSize - 1] = 0;\r\n }\r\n /*\r\n * Carve up the plaintext and encrypt each of the resultant blocks.\r\n */\r\n al = a.length;\r\n\r\n for (i = 0; i < al; i += key.chunkSize) {\r\n /*\r\n * Get a block.\r\n */\r\n block = new bigint.BigInt();\r\n\r\n j = 0;\r\n\r\n for (k = i; k < (i + key.chunkSize); ++j) {\r\n block.digits[j] = a[k++];\r\n block.digits[j] += a[k++] << 8;\r\n }\r\n /*\r\n * Encrypt it, convert it to text, and append it to the result.\r\n */\r\n crypt = key.barrett.powMod(block, key.e);\r\n if (encodingtype == 1) {\r\n text = bigint.biToBytes(crypt);\r\n } else {\r\n text = (key.radix == 16) ? bigint.biToHex(crypt) : bigint.biToString(crypt, key.radix);\r\n }\r\n result += text;\r\n }\r\n /*\r\n * Return the result, removing the last space.\r\n */\r\n //result = (result.substring(0, result.length - 1));\r\n return result;\r\n}\r\n\r\n/*****************************************************************************/\r\n\r\nexport function decryptedString(key, c)\r\n/*\r\n * key The previously-built RSA key whose\r\n * private key component is to be used\r\n * to decrypt the cyphertext string.\r\n *\r\n * c The cyphertext string that is to be\r\n * decrypted, using the RSA assymmetric\r\n * encryption method.\r\n *\r\n * returns The plaintext block that results from\r\n * decrypting the cyphertext string c\r\n * with the RSA key.\r\n *\r\n * This routine is the complementary decryption routine that is meant to be\r\n * used for JavaScript decryption of cyphertext blocks that were encrypted\r\n * using the OHDave padding method of the encryptedString routine (in this\r\n * module). It can also decrypt cyphertext blocks that were encrypted by\r\n * RSAEncode (in CryptoFuncs.pm or CryptoFuncs.php) so that encrypted\r\n * messages can be sent of insecure links (e.g. HTTP) to a Web page.\r\n *\r\n * It accepts a cyphertext string that is to be decrypted with the public key\r\n * component of the previously-built RSA key using the RSA assymmetric\r\n * encryption method. Multiple cyphertext blocks are broken apart, if they\r\n * are found in c, and each block is decrypted. All of the decrypted blocks\r\n * are concatenated back together to obtain the original plaintext string.\r\n *\r\n * This routine assumes that the plaintext was padded to the same length as\r\n * the encryption key with zeros. Therefore, it removes any zero bytes that\r\n * are found at the end of the last decrypted block, before it is appended to\r\n * the decrypted plaintext string.\r\n *\r\n * Note that the encryptedString routine (in this module) works fairly quickly\r\n * simply by virtue of the fact that the public key most often chosen is quite\r\n * short (e.g. 0x10001). This routine does not have that luxury. The\r\n * decryption key that it must employ is the full key length. For long keys,\r\n * this can result in serious timing delays (e.g. 7-8 seconds to decrypt using\r\n * 2048 bit keys on a reasonably fast machine, under the Firefox Web browser).\r\n *\r\n * If you intend to send encrypted messagess to a JavaScript program running\r\n * under a Web browser, you might consider using shorter keys to keep the\r\n * decryption times low. Alternately, a better scheme is to generate a random\r\n * key for use by a symmetric encryption algorithm and transmit it to the\r\n * other end, after encrypting it with encryptedString. The other end can use\r\n * a real crypto library (e.g. OpenSSL or Microsoft) to decrypt the key and\r\n * then use it to encrypt all of the messages (with a symmetric encryption\r\n * algorithm such as Twofish or AES) bound for the JavaScript program.\r\n * Symmetric decryption is orders of magnitude faster than asymmetric and\r\n * should yield low decryption times, even when executed in JavaScript.\r\n *\r\n * Also note that only the OHDave padding method (e.g. zeros) is supported by\r\n * this routine *AND* that this routine expects little-endian cyphertext, as\r\n * created by the encryptedString routine (in this module) or the RSAEncode\r\n * routine (in either CryptoFuncs.pm or CryptoFuncs.php). You can use one of\r\n * the real crypto libraries to create cyphertext that can be decrypted by\r\n * this routine, if you reverse the plaintext byte order first and then\r\n * manually pad it with zero bytes. The plaintext should then be encrypted\r\n * with the NoPadding flag or its equivalent in the crypto library of your\r\n * choice.\r\n */\r\n{\r\n var blocks = c.split(\" \"); // Multiple blocks of cyphertext\r\n var b; // The usual Alice and Bob stuff\r\n var i, j; // The usual Fortran index stuff\r\n var bi; // Cyphertext as a big integer\r\n var result = \"\"; // Plaintext result\r\n /*\r\n * Carve up the cyphertext into blocks.\r\n */\r\n for (i = 0; i < blocks.length; ++i) {\r\n /*\r\n * Depending on the radix being used for the key, convert this cyphertext\r\n * block into a big integer.\r\n */\r\n if (key.radix == 16) {\r\n bi = bigint.biFromHex(blocks[i]);\r\n } else {\r\n bi = bigint.biFromString(blocks[i], key.radix);\r\n }\r\n /*\r\n * Decrypt the cyphertext.\r\n */\r\n b = key.barrett.powMod(bi, key.d);\r\n /*\r\n * Convert the decrypted big integer back to the plaintext string. Since\r\n * we are using big integers, each element thereof represents two bytes of\r\n * plaintext.\r\n */\r\n for (j = 0; j <= bigint.biHighIndex(b); ++j) {\r\n result += String.fromCharCode(b.digits[j] & 255, b.digits[j] >> 8);\r\n }\r\n }\r\n /*\r\n * Remove trailing null, if any.\r\n */\r\n if (result.charCodeAt(result.length - 1) == 0) {\r\n result = result.substring(0, result.length - 1);\r\n }\r\n /*\r\n * Return the plaintext.\r\n */\r\n return (result);\r\n}","\n\n