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AUA,SAAS,YAAY,EAAM,EAAW,GAClC,IAAI,EAAO,CAAC,EACZ,IACI,EAAO,QAAQ,EACnB,CAAC,MAAM,GAEH,OAAO,CACX,CAMA,QAJiC,IAAvB,QAAQ,KACd,EAAY,QAAQ,SAGW,IAAzB,WAAW,GACjB,KAAK,8BAET,OAAG,WAAW,GAAW,MAAQ,EAAK,eACZ,IAAZ,QAAmD,IAAjB,EAAQ,MAC7C,EAAK,QAAQ,KAAO,EAAQ,IAO3C,CASA,SAAS,OAAO,EAAU,GACtB,IAAI,EAAO,QAAQ,GACnB,OAAO,WAAW,EAAK,UAAU,OAAO,EAAU,EACtD,CAEA,QAAQ,QAAU,QAClB,QAAQ,KAAO,KACf,QAAQ,YAAc,YACtB,QAAQ,OAAS","file":"/npm/node-php-password@0.1.2/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/node-php-password@0.1.2/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n * node-php-password \n *\n * @package node-php-password\n * @copyright (c) 2016, Thomas Alrek\n * @author Thomas Alrek <thomas@alrek.no>\n */\n\nvar glob = require(\"glob\");\nvar path = require('path');\nvar aliases = require(\"./package.json\").aliases;\n\n/* hold all algorithm modules */\nvar algorithms = {};\n\n/* load algorithm modules */\nglob.sync(path.resolve(__dirname+'/algorithms/*.js')).forEach(function (file) {\n    try{\n        var algorithm = require(path.resolve(file));\n        \n        /* verify loaded module */\n        if(typeof(algorithm.name) !== 'string'){\n            throw(\"Invalid module: Module has an invalid name\");\n        }\n        if(typeof algorithms[algorithm.name] !== 'undefined'){\n            throw(\"Invalid module: Multiple module instances with name '\" + algorithm.name + \"'\");\n        }\n        algorithms[algorithm.name] = algorithm;\n        if(!(algorithms[algorithm.name].expression instanceof RegExp)){\n            throw(\"Invalid module: Module has an invalid expression\");\n        }\n        if(typeof algorithms[algorithm.name].verify !== 'function'){\n            throw(\"Invalid module: Module verify() is not a valid function\");\n        }\n        if(typeof algorithms[algorithm.name].cost !== 'function'){\n            throw(\"Invalid module: Module cost() is not a valid function\");\n        }\n        if(typeof algorithms[algorithm.name].hash !== 'function'){\n            throw(\"Invalid module: Module hash() is not a valid function\");\n        }\n    }catch(e){\n        throw(\"Invalid module\");\n    }\n});\n\n/* check if any modules where loaded, otherwise throw error */\nif(algorithms.length == 0){\n    throw(\"exception no algorithms loaded\");\n}\n\n/**\n * Get information from password hash\n * @param {string} hash A password hash to check\n * @return {object} Info object\n * @throws {Exception} Will throw an exception if unable to parse hash\n */\nfunction getInfo(hash){\n    var found = false;\n    var info = {\n        algoName: \"\",\n        options: {\n            cost: 0\n        }\n    };\n    for(var key in algorithms){\n        algorithms[key].expression.lastIndex = 0;\n        if(algorithms[key].expression.test(hash)){\n            info.algoName = algorithms[key].name;\n            info.options.cost = algorithms[key].cost(hash);\n            found = true;\n            break;\n        }\n    }\n    if(!found){\n        throw(\"exception unknown algorithm\");\n    }\n    return info;\n}\n\n/**\n * Hash a password string\n * @param {string} password The plaintext password to hash\n * @param {string} algorithm Algorithm name, e.g \"PASSWORD_DEFAULT\"\n * @param {object} options Options to pass to the hashing algorithm\n * @return {string} Password hash\n * @throws {Exception} Will throw an exception if an invalid algorithm is passed\n */\nfunction hash(password, algorithm, options){\n    var algo;\n    if(typeof algorithm == 'undefined'){\n        algorithm = \"PASSWORD_DEFAULT\";\n    }\n    if(typeof options == 'undefined'){\n        options = {};\n    }\n    if(typeof aliases[algorithm] !== 'undefined'){\n        algorithm = aliases[algorithm];\n    }\n    if(typeof algorithms[algorithm] == 'undefined'){\n        throw(\"exception unknown algorithm\");\n    }\n    algo = algorithms[algorithm];\n    return algo.hash(password, options);\n}\n\n/**\n * Check if a given password needs to be rehashed\n * @param {string} hash A password hash to check\n * @param {string} algorithm Algorithm name, e.g \"PASSWORD_DEFAULT\"\n * @param {object} options Options to pass to the hashing algorithm\n * @return {bool} true if password needs rehash, otherwise false\n * @throws {Exception} Will throw an exception if an invalid algorithm is passed\n */\nfunction needsRehash(hash, algorithm, options){\n    var info = {};\n    try{\n        info = getInfo(hash);\n    }catch(e){\n        /* unable to parse hash, so we assume it's an old or unknown format */\n        return true;\n    }\n    /* check if the supplied algorithm name is an alias */\n    if(typeof aliases[algorithm] !== 'undefined'){\n        algorithm = aliases[algorithm];\n    }\n    /* unable to compare, because an invalid algorithm was supplied */\n    if(typeof algorithms[algorithm] == 'undefined'){\n        throw(\"exception unknown algorithm\");\n    }\n    if(algorithms[algorithm].name == info.algoName){\n        if(typeof options !== 'undefined' && typeof options.cost !== 'undefined'){\n            if(info.options.cost < options.cost){\n                return true;\n            }\n        }\n        return false;\n    }\n    return true;\n}\n\n/**\n * Verify a plaintext password against hash\n * @param {string} password The plaintext password to check\n * @param {string} hash A password hash to check\n * @return {bool} true if password is verified against given hash, otherwise false\n * @throws {Exception} Will throw an exception if unable to parse hash\n */\nfunction verify(password, hash){\n    var info = getInfo(hash);\n    return algorithms[info.algoName].verify(password, hash);\n}\n\nexports.getInfo = getInfo;\nexports.hash = hash;\nexports.needsRehash = needsRehash;\nexports.verify = verify;\n"]}