drupflare/worker - v1.0.4
    Preparing search index...

    Variable ARGON2_FIX_PHPConst

    ARGON2_FIX_PHP: "\nif (!function_exists('cfw_argon2_available')) {\n\t$__cfw_argon2 = function_exists('vrzno_env') ? vrzno_env('cfwArgon2') : null;\n\tif ($__cfw_argon2 !== null) {\n\t\t$GLOBALS['__cfw_argon2'] = $__cfw_argon2;\n\n\t\tfunction cfw_argon2_available(): bool\n\t\t{\n\t\t\treturn true;\n\t\t}\n\n\t\t/**\n\t\t * unpadded base64, which is what PHP's own argon2 encoding uses\n\t\t *\n\t\t * @param string $raw\n\t\t * The bytes to encode.\n\t\t */\n\t\tfunction cfw_argon2_b64($raw): string\n\t\t{\n\t\t\treturn rtrim(base64_encode($raw), '=');\n\t\t}\n\n\t\t/**\n\t\t * @param string $password\n\t\t * The password bytes.\n\t\t * @param string $salt\n\t\t * The salt bytes.\n\t\t * @param int $m\n\t\t * Memory cost in KiB.\n\t\t * @param int $t\n\t\t * Time cost.\n\t\t * @param int $p\n\t\t * Lanes.\n\t\t * @param int $tagLen\n\t\t * Output length in bytes.\n\t\t *\n\t\t * @return string|false|null\n\t\t * The raw tag, FALSE when the reply was not base64, or NULL when the host refused.\n\t\t */\n\t\tfunction cfw_argon2_raw($password, $salt, $m, $t, $p, $tagLen = 32)\n\t\t{\n\t\t\t$fn = $GLOBALS['__cfw_argon2'];\n\t\t\t$reply = json_decode(\n\t\t\t\t$fn(\n\t\t\t\t\tjson_encode([\n\t\t\t\t\t\t'op' => 'hash',\n\t\t\t\t\t\t'passB64' => base64_encode((string) $password),\n\t\t\t\t\t\t'saltB64' => base64_encode((string) $salt),\n\t\t\t\t\t\t'm' => (int) $m,\n\t\t\t\t\t\t't' => (int) $t,\n\t\t\t\t\t\t'p' => (int) $p,\n\t\t\t\t\t\t'tagLen' => (int) $tagLen,\n\t\t\t\t\t]),\n\t\t\t\t),\n\t\t\t\ttrue,\n\t\t\t);\n\t\t\tif (!is_array($reply) || ($reply['ok'] ?? false) !== true) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn base64_decode((string) ($reply['tagB64'] ?? ''), true);\n\t\t}\n\n\t\t/**\n\t\t * Hashes into PHP's own encoded form.\n\t\t *\n\t\t * @param string $password\n\t\t * The password to hash.\n\t\t * @param int $m\n\t\t * Memory cost in KiB.\n\t\t * @param int $t\n\t\t * Time cost.\n\t\t * @param int $p\n\t\t * Lanes.\n\t\t *\n\t\t * @return string|null\n\t\t * The encoded hash, or NULL when the host refused.\n\t\t */\n\t\tfunction cfw_argon2_hash($password, $m = 19456, $t = 2, $p = 1)\n\t\t{\n\t\t\t$salt = random_bytes(16);\n\t\t\t$raw = cfw_argon2_raw($password, $salt, $m, $t, $p);\n\t\t\tif ($raw === null || $raw === false) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn sprintf(\n\t\t\t\t'$argon2id$v=%d$m=%d,t=%d,p=%d$%s$%s',\n\t\t\t\t19,\n\t\t\t\t(int) $m,\n\t\t\t\t(int) $t,\n\t\t\t\t(int) $p,\n\t\t\t\tcfw_argon2_b64($salt),\n\t\t\t\tcfw_argon2_b64($raw),\n\t\t\t);\n\t\t}\n\n\t\t/**\n\t\t * Verifies against an encoded hash, in constant time.\n\t\t *\n\t\t * hash_equals() rather than ===, because a byte-at-a-time comparison of a password digest\n\t\t * is a timing oracle even when the digest itself is memory-hard.\n\t\t *\n\t\t * @param string $password\n\t\t * The password to check.\n\t\t * @param string $encoded\n\t\t * A hash cfw_argon2_hash() or PHP's own password_hash() wrote.\n\t\t */\n\t\tfunction cfw_argon2_verify($password, $encoded): bool\n\t\t{\n\t\t\t$parts = explode('$', (string) $encoded);\n\t\t\tif (count($parts) !== 6 || $parts[1] !== 'argon2id') {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t$params = [];\n\t\t\tforeach (explode(',', $parts[3]) as $pair) {\n\t\t\t\t$kv = explode('=', $pair, 2);\n\t\t\t\tif (count($kv) === 2) {\n\t\t\t\t\t$params[$kv[0]] = (int) $kv[1];\n\t\t\t\t}\n\t\t\t}\n\t\t\t$salt = base64_decode(strtr($parts[4], '-_', '+/'), false);\n\t\t\t$want = base64_decode(strtr($parts[5], '-_', '+/'), false);\n\t\t\tif ($salt === false || $want === false || $want === '') {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\t$raw = cfw_argon2_raw(\n\t\t\t\t$password,\n\t\t\t\t$salt,\n\t\t\t\t$params['m'] ?? 19456,\n\t\t\t\t$params['t'] ?? 2,\n\t\t\t\t$params['p'] ?? 1,\n\t\t\t\tstrlen($want),\n\t\t\t);\n\t\t\tif ($raw === null || $raw === false) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn hash_equals($want, $raw);\n\t\t}\n\n\t\t/**\n\t\t * whether an existing encoded hash was written with weaker parameters than today's\n\t\t *\n\t\t * @param string $encoded\n\t\t * The stored hash.\n\t\t * @param int $m\n\t\t * Memory cost in KiB.\n\t\t * @param int $t\n\t\t * Time cost.\n\t\t * @param int $p\n\t\t * Lanes.\n\t\t */\n\t\tfunction cfw_argon2_needs_rehash($encoded, $m = 19456, $t = 2, $p = 1): bool\n\t\t{\n\t\t\t$parts = explode('$', (string) $encoded);\n\t\t\tif (count($parts) !== 6 || $parts[1] !== 'argon2id') {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\t$params = [];\n\t\t\tforeach (explode(',', $parts[3]) as $pair) {\n\t\t\t\t$kv = explode('=', $pair, 2);\n\t\t\t\tif (count($kv) === 2) {\n\t\t\t\t\t$params[$kv[0]] = (int) $kv[1];\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn ($params['m'] ?? 0) < (int) $m ||\n\t\t\t\t($params['t'] ?? 0) < (int) $t ||\n\t\t\t\t($params['p'] ?? 0) !== (int) $p;\n\t\t}\n\t}\n}\n"