Course address: https://www.bilibili.com/video/BV1Mi4y147Yb
The main points of the process of completing js files by tracing back one by one with error information omitted by the up master (find and paste the following codes into js to complete and run smoothly):
CryptoJS variable
Previously on: at 13:13 of the up main course video, the windows variable was just deleted, and now an error is reported that CryptoJS is not defined.
CryptoJS appears 13 times in the web page source js code. In addition to the first function that has been pasted into our js file, CryptoJS also appears in the other 6 functions in the source js code.
In order to prevent the console from outputting 'CryptoJS undefined', we need to completely copy all the functions that CryptoJS has appeared in the source js code and paste them into our js file.
For the other six functions that need to be found, the up master does not find them one by one. My personal search process is summarized as follows.
- Find the first function of CryptoJS in the web page source code js:
var CryptoJS = CryptoJS || function(u, p) {...}(Math);
- Places 2 to 4 are three unnamed functions between places 1 and 5:
//Place 2 (function() { ...} )(); //Place 3 (function(u) { ...} )(Math); //Place 4 (function() { ...} )();
Position 5 follows position 4:
CryptoJS.lib.Cipher || function(u) {...}();
Place 6 is an unnamed function immediately following place 5:
(function() { //CryptoJS appears in the first line of the function for (var u = CryptoJS, ...} )();
Defining variables in a segment set
Next, an error will be reported that maxDigitVal is not defined. Therefore, the following large section of code will be found, which defines many variables including maxDigitVal:
var maxDigits, ZERO_ARRAY, bigZero, bigOne, dpl10, lr10, hexatrigesimalToChar, hexToChar, highBitMasks, lowBitMasks, biRadixBase = 2, biRadixBits = 16, bitsPerDigit = biRadixBits, biRadix = 65536, biHalfRadix = biRadix >>> 1, biRadixSquared = biRadix * biRadix, maxDigitVal = biRadix - 1, maxInteger = 9999999999999998; setMaxDigits(20), dpl10 = 15, lr10 = biFromNumber(1e15), hexatrigesimalToChar = new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"), hexToChar = new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"), highBitMasks = new Array(0,32768,49152,57344,61440,63488,64512,65024,65280,65408,65472,65504,65520,65528,65532,65534,65535), lowBitMasks = new Array(0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535);
Find this large section of variable definition, copy and paste it into our js file.
The rest are all functions (30 in total)
Then, the rest of the error reports are all function names, with a total of 30. They are unordered (not in the order in which they appear in the source js code) as follows, with 6 in each line separated by spaces:
setMaxDigits BigInt biFromNumber biFromHex hexToDigit charToHex
biHighIndex BarrettMu biCopy biDivide biDivideModulo biNumBits
biShiftLeft arrayCopy biMultiplyByRadixPower biCompare biSubtract biMultiplyDigit
biShiftRight BarrettMu_modulo biDivideByRadixPower biModuloByRadixPower BarrettMu_multiplyMod BarrettMu_powMod
encryptedString biToHex digitToHex reverseStr biMultiply RSAKeyPair
Find definitions one by one according to the name, and then copy and paste them into our js file, so we won't report the error of "undefined" type again.
Take the setMaxDigits function as an example. Search 'setMaxDigits' in the source js code and see the definition header such as function setMaxDigits(a) {. Copy the whole function and paste it into our js file, and so on. All 30 functions are ok.
Output results successfully
The console will no longer report errors, and the successful output results are as follows.
{'params': 'OPYiEeviGUsvOLMa7cENWV7bCk8iZ2CmHlw6hVUAgWc5nibtrcYDJvWXChluboDZQ1Fb3xp6p8r/wPPCBZ2gQQtGGkha6mAum5MAuv/gbGVFys/ziQWBL62d2YCtv4EnnEW/oMUKbqLWfFvD4tdMebZ5yU8g5SRSDA3FUWxgy7JQbFnQWOrkV7nCKUYG/mo/RrcCMXw3bzWrneVMrw7MEJfImsLZ1zFKLAcicx6Sagh02FkeVMDgTJCR4regbpPu1LoKRezCFk3oE0ahIwIzgsJvrKewIrYn+XjXXEXNt6E=', 'encSecKey': '3da8f6c2b63a75b7ed2c3c2220c5396f6116cf96cab3be9f32d3adf6b33123729b38ac69c0520a735fb269c72847ccb753a77d401079c9ea7ae86329d66c697ba8ba9dc4aab08f1d17f04037f03547695b7d4949672da2ef9246f7c9d9bd3bba4059f2bcde6ab5e74103a453bb2e20a1298350764bf9cca0e403ade8704bb08e'}