{"version":3,"sources":["../../../src/php/strings/sha1.js"],"names":["module","exports","sha1","str","hash","crypto","require","sha1sum","createHash","update","digest","e","undefined","_rotLeft","n","s","t4","_cvtHex","val","i","v","toString","blockstart","j","W","Array","H0","H1","H2","H3","H4","A","B","C","D","E","temp","unescape","encodeURIComponent","strLen","length","wordArray","charCodeAt","push","toLowerCase"],"mappings":";;AAAAA,OAAOC,OAAP,GAAiB,SAASC,IAAT,CAAeC,GAAf,EAAoB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAIC,IAAJ;AACA,MAAI;AACF,QAAIC,SAASC,QAAQ,QAAR,CAAb;AACA,QAAIC,UAAUF,OAAOG,UAAP,CAAkB,MAAlB,CAAd;AACAD,YAAQE,MAAR,CAAeN,GAAf;AACAC,WAAOG,QAAQG,MAAR,CAAe,KAAf,CAAP;AACD,GALD,CAKE,OAAOC,CAAP,EAAU;AACVP,WAAOQ,SAAP;AACD;;AAED,MAAIR,SAASQ,SAAb,EAAwB;AACtB,WAAOR,IAAP;AACD;;AAED,MAAIS,WAAW,SAAXA,QAAW,CAAUC,CAAV,EAAaC,CAAb,EAAgB;AAC7B,QAAIC,KAAMF,KAAKC,CAAN,GAAYD,MAAO,KAAKC,CAAjC;AACA,WAAOC,EAAP;AACD,GAHD;;AAKA,MAAIC,UAAU,SAAVA,OAAU,CAAUC,GAAV,EAAe;AAC3B,QAAIf,MAAM,EAAV;AACA,QAAIgB,CAAJ;AACA,QAAIC,CAAJ;;AAEA,SAAKD,IAAI,CAAT,EAAYA,KAAK,CAAjB,EAAoBA,GAApB,EAAyB;AACvBC,UAAKF,QAASC,IAAI,CAAd,GAAoB,IAAxB;AACAhB,aAAOiB,EAAEC,QAAF,CAAW,EAAX,CAAP;AACD;AACD,WAAOlB,GAAP;AACD,GAVD;;AAYA,MAAImB,UAAJ;AACA,MAAIH,CAAJ,EAAOI,CAAP;AACA,MAAIC,IAAI,IAAIC,KAAJ,CAAU,EAAV,CA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AAKK,CAAN,GAAW,WAAhB;AACD;;AAEDC,SAAOnB,QAAQS,EAAR,IAAcT,QAAQU,EAAR,CAAd,GAA4BV,QAAQW,EAAR,CAA5B,GAA0CX,QAAQY,EAAR,CAA1C,GAAwDZ,QAAQa,EAAR,CAA/D;AACA,SAAOM,KAAKQ,WAAL,EAAP;AACD,CAzJD","file":"sha1.js","sourcesContent":["module.exports = function sha1 (str) {\n // discuss at: http://locutus.io/php/sha1/\n // original by: Webtoolkit.info (http://www.webtoolkit.info/)\n // improved by: Michael White (http://getsprink.com)\n // improved by: Kevin van Zonneveld (http://kvz.io)\n // input by: Brett Zamir (http://brett-zamir.me)\n // note 1: Keep in mind that in accordance with PHP, the whole string is buffered and then\n // note 1: hashed. If available, we'd recommend using Node's native crypto modules directly\n // note 1: in a steaming fashion for faster and more efficient hashing\n // example 1: sha1('Kevin van Zonneveld')\n // returns 1: '54916d2e62f65b3afa6e192e6a601cdbe5cb5897'\n\n var hash\n try {\n var crypto = require('crypto')\n var sha1sum = crypto.createHash('sha1')\n sha1sum.update(str)\n hash = sha1sum.digest('hex')\n } catch (e) {\n hash = undefined\n }\n\n if (hash !== undefined) {\n return hash\n }\n\n var _rotLeft = function (n, s) {\n var t4 = (n << s) | (n >>> (32 - s))\n return t4\n }\n\n var _cvtHex = function (val) {\n var str = ''\n var i\n var v\n\n for (i = 7; i >= 0; i--) {\n v = (val >>> (i * 4)) & 0x0f\n str += v.toString(16)\n }\n return str\n }\n\n var blockstart\n var i, j\n var W = new Array(80)\n var H0 = 0x67452301\n var H1 = 0xEFCDAB89\n var H2 = 0x98BADCFE\n var H3 = 0x10325476\n var H4 = 0xC3D2E1F0\n var A, B, C, D, E\n var temp\n\n // utf8_encode\n str = unescape(encodeURIComponent(str))\n var strLen = str.length\n\n var wordArray = []\n for (i = 0; i < strLen - 3; i += 4) {\n j = str.charCodeAt(i) << 24 |\n str.charCodeAt(i + 1) << 16 |\n str.charCodeAt(i + 2) << 8 |\n str.charCodeAt(i + 3)\n wordArray.push(j)\n }\n\n switch (strLen % 4) {\n case 0:\n i = 0x080000000\n break\n case 1:\n i = str.charCodeAt(strLen - 1) << 24 | 0x0800000\n break\n case 2:\n i = str.charCodeAt(strLen - 2) << 24 | str.charCodeAt(strLen - 1) << 16 | 0x08000\n break\n case 3:\n i = str.charCodeAt(strLen - 3) << 24 |\n str.charCodeAt(strLen - 2) << 16 |\n str.charCodeAt(strLen - 1) <<\n 8 | 0x80\n break\n }\n\n wordArray.push(i)\n\n while ((wordArray.length % 16) !== 14) {\n wordArray.push(0)\n }\n\n wordArray.push(strLen >>> 29)\n wordArray.push((strLen << 3) & 0x0ffffffff)\n\n for (blockstart = 0; blockstart < wordArray.length; blockstart += 16) {\n for (i = 0; i < 16; i++) {\n W[i] = wordArray[blockstart + i]\n }\n for (i = 16; i <= 79; i++) {\n W[i] = _rotLeft(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1)\n }\n\n A = H0\n B = H1\n C = H2\n D = H3\n E = H4\n\n for (i = 0; i <= 19; i++) {\n temp = (_rotLeft(A, 5) + ((B & C) | (~B & D)) + E + W[i] + 0x5A827999) & 0x0ffffffff\n E = D\n D = C\n C = _rotLeft(B, 30)\n B = A\n A = temp\n }\n\n for (i = 20; i <= 39; i++) {\n temp = (_rotLeft(A, 5) + (B ^ C ^ D) + E + W[i] + 0x6ED9EBA1) & 0x0ffffffff\n E = D\n D = C\n C = _rotLeft(B, 30)\n B = A\n A = temp\n }\n\n for (i = 40; i <= 59; i++) {\n temp = (_rotLeft(A, 5) + ((B & C) | (B & D) | (C & D)) + E + W[i] + 0x8F1BBCDC) & 0x0ffffffff\n E = D\n D = C\n C = _rotLeft(B, 30)\n B = A\n A = temp\n }\n\n for (i = 60; i <= 79; i++) {\n temp = (_rotLeft(A, 5) + (B ^ C ^ D) + E + W[i] + 0xCA62C1D6) & 0x0ffffffff\n E = D\n D = C\n C = _rotLeft(B, 30)\n B = A\n A = temp\n }\n\n H0 = (H0 + A) & 0x0ffffffff\n H1 = (H1 + B) & 0x0ffffffff\n H2 = (H2 + C) & 0x0ffffffff\n H3 = (H3 + D) & 0x0ffffffff\n H4 = (H4 + E) & 0x0ffffffff\n }\n\n temp = _cvtHex(H0) + _cvtHex(H1) + _cvtHex(H2) + _cvtHex(H3) + _cvtHex(H4)\n return temp.toLowerCase()\n}\n"]}