[
  {
    "path": ".gitignore",
    "content": "#Mac\n.DS_Store\n#Vscode\n.vscode/*\n!.vscode/settings.json\n!.vscode/tasks.json\n!.vscode/launch.json\n!.vscode/extensions.json\n#nodejs\nnode_modules\nnpm-debug.log\n# Windows image file caches\nThumbs.db\nehthumbs.db\n# Folder config file\nDesktop.ini\n"
  },
  {
    "path": "README.md",
    "content": "# vPlayer\n\n用vuejs写的播放器，API基于网易云, 具体效果请查看Demo！\n\nDemo: http://player.ciyuanai.net\n\n已更新使用网易云新版API，国外ip使用会被屏蔽，请注意！\n\n演示站点环境：Vuejs v2.1.10 + vue-resource v1.0.3 + php7 + nginx\n\n因为api那边用的是网易云新版v2 api，所以推荐使用php5.6以上版本，并开启openssl模块\n"
  },
  {
    "path": "api/detail.php",
    "content": "<?php\nheader('Content-Type: application/json');\n\nrequire dirname(__FILE__) . '/v2/MusicAPI.php';\n\n$api = new MusicAPI();\n\n$id = $_GET['id'];\n\nif (!empty($id)) {\n  $detail = $api->detail($id);\n  print_r($detail);\n}"
  },
  {
    "path": "api/lyric.php",
    "content": "<?php\nheader('Content-Type: application/json');\n\nrequire dirname(__FILE__) . '/v2/MusicAPI.php';\n\n$api = new MusicAPI();\n\n$id = $_GET['id'];\n\nif (!empty($id)) {\n\t$result = $api->lyric($id);\n\tprint_r($result);\n}"
  },
  {
    "path": "api/mp3url.php",
    "content": "<?php\nheader('Content-Type: application/json');\n\nrequire dirname(__FILE__) . '/v2/MusicAPI.php';\n\n$api = new MusicAPI();\n\n$song_id = $_GET['id'];\n\nif (!empty($song_id)) {\n  $mp3url = $api->mp3url($song_id);\n  print_r($mp3url);\n} else {\n\treturn;\n}"
  },
  {
    "path": "api/pages.php",
    "content": "<?php\nheader('Content-Type: application/json');\n\nrequire dirname(__FILE__) . '/v2/MusicAPI.php';\n\n$api = new MusicAPI();\n\n$p = $_GET['p'];\n$s = $_GET['s'];\n\nif (!empty($s) && !empty($p)) {\n  $result = $api->search($s, 30, $p);\n  print_r($result);\n} elseif ($p == 0 || empty($p)) {\n  $result = $api->search($s, 30);\n  print_r($result);\n}"
  },
  {
    "path": "api/search.php",
    "content": "<?php\nheader('Content-Type: application/json');\n\nrequire dirname(__FILE__) . '/v2/MusicAPI.php';\n\n$api = new MusicAPI();\n\n$s = $_GET['s'];\n\nif (!empty($s)) {\n  $result = $api->search($s, 30);\n  print_r($result);\n}\n"
  },
  {
    "path": "api/v2/BigInteger.php",
    "content": "<?php\n\n/**\n * Pure-PHP arbitrary precision integer arithmetic library.\n *\n * Supports base-2, base-10, base-16, and base-256 numbers.  Uses the GMP or BCMath extensions, if available,\n * and an internal implementation, otherwise.\n *\n * PHP versions 4 and 5\n *\n * {@internal (all DocBlock comments regarding implementation - such as the one that follows - refer to the\n * {@link MATH_BIGINTEGER_MODE_INTERNAL MATH_BIGINTEGER_MODE_INTERNAL} mode)\n *\n * Math_BigInteger uses base-2**26 to perform operations such as multiplication and division and\n * base-2**52 (ie. two base 2**26 digits) to perform addition and subtraction.  Because the largest possible\n * value when multiplying two base-2**26 numbers together is a base-2**52 number, double precision floating\n * point numbers - numbers that should be supported on most hardware and whose significand is 53 bits - are\n * used.  As a consequence, bitwise operators such as >> and << cannot be used, nor can the modulo operator %,\n * which only supports integers.  Although this fact will slow this library down, the fact that such a high\n * base is being used should more than compensate.\n *\n * When PHP version 6 is officially released, we'll be able to use 64-bit integers.  This should, once again,\n * allow bitwise operators, and will increase the maximum possible base to 2**31 (or 2**62 for addition /\n * subtraction).\n *\n * Numbers are stored in {@link http://en.wikipedia.org/wiki/Endianness little endian} format.  ie.\n * (new Math_BigInteger(pow(2, 26)))->value = array(0, 1)\n *\n * Useful resources are as follows:\n *\n *  - {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf Handbook of Applied Cryptography (HAC)}\n *  - {@link http://math.libtomcrypt.com/files/tommath.pdf Multi-Precision Math (MPM)}\n *  - Java's BigInteger classes.  See /j2se/src/share/classes/java/math in jdk-1_5_0-src-jrl.zip\n *\n * Here's an example of how to use this library:\n * <code>\n * <?php\n *    include('Math/BigInteger.php');\n *\n *    $a = new Math_BigInteger(2);\n *    $b = new Math_BigInteger(3);\n *\n *    $c = $a->add($b);\n *\n *    echo $c->toString(); // outputs 5\n * ?>\n * </code>\n *\n * LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n *\n * @category  Math\n * @package   Math_BigInteger\n * @author    Jim Wigginton <terrafrost@php.net>\n * @copyright MMVI Jim Wigginton\n * @license   http://www.opensource.org/licenses/mit-license.html  MIT License\n * @link      http://pear.php.net/package/Math_BigInteger\n */\n\n/**#@+\n * Reduction constants\n *\n * @access private\n * @see Math_BigInteger::_reduce()\n */\n/**\n * @see Math_BigInteger::_montgomery()\n * @see Math_BigInteger::_prepMontgomery()\n */\ndefine('MATH_BIGINTEGER_MONTGOMERY', 0);\n/**\n * @see Math_BigInteger::_barrett()\n */\ndefine('MATH_BIGINTEGER_BARRETT', 1);\n/**\n * @see Math_BigInteger::_mod2()\n */\ndefine('MATH_BIGINTEGER_POWEROF2', 2);\n/**\n * @see Math_BigInteger::_remainder()\n */\ndefine('MATH_BIGINTEGER_CLASSIC', 3);\n/**\n * @see Math_BigInteger::__clone()\n */\ndefine('MATH_BIGINTEGER_NONE', 4);\n/**#@-*/\n\n/**#@+\n * Array constants\n *\n * Rather than create a thousands and thousands of new Math_BigInteger objects in repeated function calls to add() and\n * multiply() or whatever, we'll just work directly on arrays, taking them in as parameters and returning them.\n *\n * @access private\n */\n/**\n * $result[MATH_BIGINTEGER_VALUE] contains the value.\n */\ndefine('MATH_BIGINTEGER_VALUE', 0);\n/**\n * $result[MATH_BIGINTEGER_SIGN] contains the sign.\n */\ndefine('MATH_BIGINTEGER_SIGN', 1);\n/**#@-*/\n\n/**#@+\n * @access private\n * @see Math_BigInteger::_montgomery()\n * @see Math_BigInteger::_barrett()\n */\n/**\n * Cache constants\n *\n * $cache[MATH_BIGINTEGER_VARIABLE] tells us whether or not the cached data is still valid.\n */\ndefine('MATH_BIGINTEGER_VARIABLE', 0);\n/**\n * $cache[MATH_BIGINTEGER_DATA] contains the cached data.\n */\ndefine('MATH_BIGINTEGER_DATA', 1);\n/**#@-*/\n\n/**#@+\n * Mode constants.\n *\n * @access private\n * @see Math_BigInteger::Math_BigInteger()\n */\n/**\n * To use the pure-PHP implementation\n */\ndefine('MATH_BIGINTEGER_MODE_INTERNAL', 1);\n/**\n * To use the BCMath library\n *\n * (if enabled; otherwise, the internal implementation will be used)\n */\ndefine('MATH_BIGINTEGER_MODE_BCMATH', 2);\n/**\n * To use the GMP library\n *\n * (if present; otherwise, either the BCMath or the internal implementation will be used)\n */\ndefine('MATH_BIGINTEGER_MODE_GMP', 3);\n/**#@-*/\n\n/**\n * Karatsuba Cutoff\n *\n * At what point do we switch between Karatsuba multiplication and schoolbook long multiplication?\n *\n * @access private\n */\ndefine('MATH_BIGINTEGER_KARATSUBA_CUTOFF', 25);\n\n/**\n * Pure-PHP arbitrary precision integer arithmetic library. Supports base-2, base-10, base-16, and base-256\n * numbers.\n *\n * @package Math_BigInteger\n * @author  Jim Wigginton <terrafrost@php.net>\n * @version 1.0.0RC4\n * @access  public\n */\nclass Math_BigInteger\n{\n    /**\n     * Holds the BigInteger's value.\n     *\n     * @var Array\n     * @access private\n     */\n    var $value;\n\n    /**\n     * Holds the BigInteger's magnitude.\n     *\n     * @var Boolean\n     * @access private\n     */\n    var $is_negative = false;\n\n    /**\n     * Random number generator function\n     *\n     * @see setRandomGenerator()\n     * @access private\n     */\n    var $generator = 'mt_rand';\n\n    /**\n     * Precision\n     *\n     * @see setPrecision()\n     * @access private\n     */\n    var $precision = -1;\n\n    /**\n     * Precision Bitmask\n     *\n     * @see setPrecision()\n     * @access private\n     */\n    var $bitmask = false;\n\n    /**\n     * Mode independent value used for serialization.\n     *\n     * If the bcmath or gmp extensions are installed $this->value will be a non-serializable resource, hence the need for\n     * a variable that'll be serializable regardless of whether or not extensions are being used.  Unlike $this->value,\n     * however, $this->hex is only calculated when $this->__sleep() is called.\n     *\n     * @see __sleep()\n     * @see __wakeup()\n     * @var String\n     * @access private\n     */\n    var $hex;\n\n    /**\n     * Converts base-2, base-10, base-16, and binary strings (base-256) to BigIntegers.\n     *\n     * If the second parameter - $base - is negative, then it will be assumed that the number's are encoded using\n     * two's compliment.  The sole exception to this is -10, which is treated the same as 10 is.\n     *\n     * Here's an example:\n     * <code>\n     * &lt;?php\n     *    include('Math/BigInteger.php');\n     *\n     *    $a = new Math_BigInteger('0x32', 16); // 50 in base-16\n     *\n     *    echo $a->toString(); // outputs 50\n     * ?&gt;\n     * </code>\n     *\n     * @param optional $x base-10 number or base-$base number if $base set.\n     * @param optional integer $base\n     * @return Math_BigInteger\n     * @access public\n     */\n    function __construct($x = 0, $base = 10)\n    {\n        if ( !defined('MATH_BIGINTEGER_MODE') ) {\n            switch (true) {\n                case extension_loaded('gmp'):\n                    define('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_GMP);\n                    break;\n                case extension_loaded('bcmath'):\n                    define('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_BCMATH);\n                    break;\n                default:\n                    define('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL);\n            }\n        }\n\n        if (function_exists('openssl_public_encrypt') && !defined('MATH_BIGINTEGER_OPENSSL_DISABLE') && !defined('MATH_BIGINTEGER_OPENSSL_ENABLED')) {\n            // some versions of XAMPP have mismatched versions of OpenSSL which causes it not to work\n            ob_start();\n            phpinfo();\n            $content = ob_get_contents();\n            ob_end_clean();\n\n            preg_match_all('#OpenSSL (Header|Library) Version(.*)#im', $content, $matches);\n\n            $versions = array();\n            if (!empty($matches[1])) {\n                for ($i = 0; $i < count($matches[1]); $i++) {\n                    $versions[$matches[1][$i]] = trim(str_replace('=>', '', strip_tags($matches[2][$i])));\n                }\n            }\n\n            // it doesn't appear that OpenSSL versions were reported upon until PHP 5.3+\n            switch (true) {\n                case !isset($versions['Header']):\n                case !isset($versions['Library']):\n                case $versions['Header'] == $versions['Library']:\n                    define('MATH_BIGINTEGER_OPENSSL_ENABLED', true);\n                    break;\n                default:\n                    define('MATH_BIGINTEGER_OPENSSL_DISABLE', true);\n            }\n        }\n\n        if (!defined('PHP_INT_SIZE')) {\n            define('PHP_INT_SIZE', 4);\n        }\n\n        if (!defined('MATH_BIGINTEGER_BASE') && MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_INTERNAL) {\n            switch (PHP_INT_SIZE) {\n                case 8: // use 64-bit integers if int size is 8 bytes\n                    define('MATH_BIGINTEGER_BASE',       31);\n                    define('MATH_BIGINTEGER_BASE_FULL',  0x80000000);\n                    define('MATH_BIGINTEGER_MAX_DIGIT',  0x7FFFFFFF);\n                    define('MATH_BIGINTEGER_MSB',        0x40000000);\n                    // 10**9 is the closest we can get to 2**31 without passing it\n                    define('MATH_BIGINTEGER_MAX10',      1000000000);\n                    define('MATH_BIGINTEGER_MAX10_LEN',  9);\n                    // the largest digit that may be used in addition / subtraction\n                    define('MATH_BIGINTEGER_MAX_DIGIT2', pow(2, 62));\n                    break;\n                //case 4: // use 64-bit floats if int size is 4 bytes\n                default:\n                    define('MATH_BIGINTEGER_BASE',       26);\n                    define('MATH_BIGINTEGER_BASE_FULL',  0x4000000);\n                    define('MATH_BIGINTEGER_MAX_DIGIT',  0x3FFFFFF);\n                    define('MATH_BIGINTEGER_MSB',        0x2000000);\n                    // 10**7 is the closest to 2**26 without passing it\n                    define('MATH_BIGINTEGER_MAX10',      10000000);\n                    define('MATH_BIGINTEGER_MAX10_LEN',  7);\n                    // the largest digit that may be used in addition / subtraction\n                    // we do pow(2, 52) instead of using 4503599627370496 directly because some\n                    // PHP installations will truncate 4503599627370496.\n                    define('MATH_BIGINTEGER_MAX_DIGIT2', pow(2, 52));\n            }\n        }\n\n        switch ( MATH_BIGINTEGER_MODE ) {\n            case MATH_BIGINTEGER_MODE_GMP:\n                if (is_resource($x) && get_resource_type($x) == 'GMP integer') {\n                    $this->value = $x;\n                    return;\n                }\n                $this->value = gmp_init(0);\n                break;\n            case MATH_BIGINTEGER_MODE_BCMATH:\n                $this->value = '0';\n                break;\n            default:\n                $this->value = array();\n        }\n\n        // '0' counts as empty() but when the base is 256 '0' is equal to ord('0') or 48\n        // '0' is the only value like this per http://php.net/empty\n        if (empty($x) && (abs($base) != 256 || $x !== '0')) {\n            return;\n        }\n\n        switch ($base) {\n            case -256:\n                if (ord($x[0]) & 0x80) {\n                    $x = ~$x;\n                    $this->is_negative = true;\n                }\n            case  256:\n                switch ( MATH_BIGINTEGER_MODE ) {\n                    case MATH_BIGINTEGER_MODE_GMP:\n                        $sign = $this->is_negative ? '-' : '';\n                        $this->value = gmp_init($sign . '0x' . bin2hex($x));\n                        break;\n                    case MATH_BIGINTEGER_MODE_BCMATH:\n                        // round $len to the nearest 4 (thanks, DavidMJ!)\n                        $len = (strlen($x) + 3) & 0xFFFFFFFC;\n\n                        $x = str_pad($x, $len, chr(0), STR_PAD_LEFT);\n\n                        for ($i = 0; $i < $len; $i+= 4) {\n                            $this->value = bcmul($this->value, '4294967296', 0); // 4294967296 == 2**32\n                            $this->value = bcadd($this->value, 0x1000000 * ord($x[$i]) + ((ord($x[$i + 1]) << 16) | (ord($x[$i + 2]) << 8) | ord($x[$i + 3])), 0);\n                        }\n\n                        if ($this->is_negative) {\n                            $this->value = '-' . $this->value;\n                        }\n\n                        break;\n                    // converts a base-2**8 (big endian / msb) number to base-2**26 (little endian / lsb)\n                    default:\n                        while (strlen($x)) {\n                            $this->value[] = $this->_bytes2int($this->_base256_rshift($x, MATH_BIGINTEGER_BASE));\n                        }\n                }\n\n                if ($this->is_negative) {\n                    if (MATH_BIGINTEGER_MODE != MATH_BIGINTEGER_MODE_INTERNAL) {\n                        $this->is_negative = false;\n                    }\n                    $temp = $this->add(new Math_BigInteger('-1'));\n                    $this->value = $temp->value;\n                }\n                break;\n            case  16:\n            case -16:\n                if ($base > 0 && $x[0] == '-') {\n                    $this->is_negative = true;\n                    $x = substr($x, 1);\n                }\n\n                $x = preg_replace('#^(?:0x)?([A-Fa-f0-9]*).*#', '$1', $x);\n\n                $is_negative = false;\n                if ($base < 0 && hexdec($x[0]) >= 8) {\n                    $this->is_negative = $is_negative = true;\n                    $x = bin2hex(~pack('H*', $x));\n                }\n\n                switch ( MATH_BIGINTEGER_MODE ) {\n                    case MATH_BIGINTEGER_MODE_GMP:\n                        $temp = $this->is_negative ? '-0x' . $x : '0x' . $x;\n                        $this->value = gmp_init($temp);\n                        $this->is_negative = false;\n                        break;\n                    case MATH_BIGINTEGER_MODE_BCMATH:\n                        $x = ( strlen($x) & 1 ) ? '0' . $x : $x;\n                        $temp = new Math_BigInteger(pack('H*', $x), 256);\n                        $this->value = $this->is_negative ? '-' . $temp->value : $temp->value;\n                        $this->is_negative = false;\n                        break;\n                    default:\n                        $x = ( strlen($x) & 1 ) ? '0' . $x : $x;\n                        $temp = new Math_BigInteger(pack('H*', $x), 256);\n                        $this->value = $temp->value;\n                }\n\n                if ($is_negative) {\n                    $temp = $this->add(new Math_BigInteger('-1'));\n                    $this->value = $temp->value;\n                }\n                break;\n            case  10:\n            case -10:\n                // (?<!^)(?:-).*: find any -'s that aren't at the beginning and then any characters that follow that\n                // (?<=^|-)0*: find any 0's that are preceded by the start of the string or by a - (ie. octals)\n                // [^-0-9].*: find any non-numeric characters and then any characters that follow that\n                $x = preg_replace('#(?<!^)(?:-).*|(?<=^|-)0*|[^-0-9].*#', '', $x);\n\n                switch ( MATH_BIGINTEGER_MODE ) {\n                    case MATH_BIGINTEGER_MODE_GMP:\n                        $this->value = gmp_init($x);\n                        break;\n                    case MATH_BIGINTEGER_MODE_BCMATH:\n                        // explicitly casting $x to a string is necessary, here, since doing $x[0] on -1 yields different\n                        // results then doing it on '-1' does (modInverse does $x[0])\n                        $this->value = $x === '-' ? '0' : (string) $x;\n                        break;\n                    default:\n                        $temp = new Math_BigInteger();\n\n                        $multiplier = new Math_BigInteger();\n                        $multiplier->value = array(MATH_BIGINTEGER_MAX10);\n\n                        if ($x[0] == '-') {\n                            $this->is_negative = true;\n                            $x = substr($x, 1);\n                        }\n\n                        $x = str_pad($x, strlen($x) + ((MATH_BIGINTEGER_MAX10_LEN - 1) * strlen($x)) % MATH_BIGINTEGER_MAX10_LEN, 0, STR_PAD_LEFT);\n                        while (strlen($x)) {\n                            $temp = $temp->multiply($multiplier);\n                            $temp = $temp->add(new Math_BigInteger($this->_int2bytes(substr($x, 0, MATH_BIGINTEGER_MAX10_LEN)), 256));\n                            $x = substr($x, MATH_BIGINTEGER_MAX10_LEN);\n                        }\n\n                        $this->value = $temp->value;\n                }\n                break;\n            case  2: // base-2 support originally implemented by Lluis Pamies - thanks!\n            case -2:\n                if ($base > 0 && $x[0] == '-') {\n                    $this->is_negative = true;\n                    $x = substr($x, 1);\n                }\n\n                $x = preg_replace('#^([01]*).*#', '$1', $x);\n                $x = str_pad($x, strlen($x) + (3 * strlen($x)) % 4, 0, STR_PAD_LEFT);\n\n                $str = '0x';\n                while (strlen($x)) {\n                    $part = substr($x, 0, 4);\n                    $str.= dechex(bindec($part));\n                    $x = substr($x, 4);\n                }\n\n                if ($this->is_negative) {\n                    $str = '-' . $str;\n                }\n\n                $temp = new Math_BigInteger($str, 8 * $base); // ie. either -16 or +16\n                $this->value = $temp->value;\n                $this->is_negative = $temp->is_negative;\n\n                break;\n            default:\n                // base not supported, so we'll let $this == 0\n        }\n    }\n\n    /**\n     * This function exists to maintain backwards compatibility with older code\n     *\n     * @param int $x    base-10 number or base-$base number if $base set.\n     * @param int $base Number base\n     */\n    public function Math_BigInteger($x = 0, $base = 10)\n    {\n        self::__construct($x, $base);\n    }\n\n    /**\n     * Converts a BigInteger to a byte string (eg. base-256).\n     *\n     * Negative numbers are saved as positive numbers, unless $twos_compliment is set to true, at which point, they're\n     * saved as two's compliment.\n     *\n     * Here's an example:\n     * <code>\n     * <?php\n     *    include('Math/BigInteger.php');\n     *\n     *    $a = new Math_BigInteger('65');\n     *\n     *    echo $a->toBytes(); // outputs chr(65)\n     * ?>\n     * </code>\n     *\n     * @param Boolean $twos_compliment\n     * @return String\n     * @access public\n     * @internal Converts a base-2**26 number to base-2**8\n     */\n    function toBytes($twos_compliment = false)\n    {\n        if ($twos_compliment) {\n            $comparison = $this->compare(new Math_BigInteger());\n            if ($comparison == 0) {\n                return $this->precision > 0 ? str_repeat(chr(0), ($this->precision + 1) >> 3) : '';\n            }\n\n            $temp = $comparison < 0 ? $this->add(new Math_BigInteger(1)) : $this->copy();\n            $bytes = $temp->toBytes();\n\n            if (empty($bytes)) { // eg. if the number we're trying to convert is -1\n                $bytes = chr(0);\n            }\n\n            if (ord($bytes[0]) & 0x80) {\n                $bytes = chr(0) . $bytes;\n            }\n\n            return $comparison < 0 ? ~$bytes : $bytes;\n        }\n\n        switch ( MATH_BIGINTEGER_MODE ) {\n            case MATH_BIGINTEGER_MODE_GMP:\n                if (gmp_cmp($this->value, gmp_init(0)) == 0) {\n                    return $this->precision > 0 ? str_repeat(chr(0), ($this->precision + 1) >> 3) : '';\n                }\n\n                $temp = gmp_strval(gmp_abs($this->value), 16);\n                $temp = ( strlen($temp) & 1 ) ? '0' . $temp : $temp;\n                $temp = pack('H*', $temp);\n\n                return $this->precision > 0 ?\n                    substr(str_pad($temp, $this->precision >> 3, chr(0), STR_PAD_LEFT), -($this->precision >> 3)) :\n                    ltrim($temp, chr(0));\n            case MATH_BIGINTEGER_MODE_BCMATH:\n                if ($this->value === '0') {\n                    return $this->precision > 0 ? str_repeat(chr(0), ($this->precision + 1) >> 3) : '';\n                }\n\n                $value = '';\n                $current = $this->value;\n\n                if ($current[0] == '-') {\n                    $current = substr($current, 1);\n                }\n\n                while (bccomp($current, '0', 0) > 0) {\n                    $temp = bcmod($current, '16777216');\n                    $value = chr($temp >> 16) . chr($temp >> 8) . chr($temp) . $value;\n                    $current = bcdiv($current, '16777216', 0);\n                }\n\n                return $this->precision > 0 ?\n                    substr(str_pad($value, $this->precision >> 3, chr(0), STR_PAD_LEFT), -($this->precision >> 3)) :\n                    ltrim($value, chr(0));\n        }\n\n        if (!count($this->value)) {\n            return $this->precision > 0 ? str_repeat(chr(0), ($this->precision + 1) >> 3) : '';\n        }\n        $result = $this->_int2bytes($this->value[count($this->value) - 1]);\n\n        $temp = $this->copy();\n\n        for ($i = count($temp->value) - 2; $i >= 0; --$i) {\n            $temp->_base256_lshift($result, MATH_BIGINTEGER_BASE);\n            $result = $result | str_pad($temp->_int2bytes($temp->value[$i]), strlen($result), chr(0), STR_PAD_LEFT);\n        }\n\n        return $this->precision > 0 ?\n            str_pad(substr($result, -(($this->precision + 7) >> 3)), ($this->precision + 7) >> 3, chr(0), STR_PAD_LEFT) :\n            $result;\n    }\n\n    /**\n     * Converts a BigInteger to a hex string (eg. base-16)).\n     *\n     * Negative numbers are saved as positive numbers, unless $twos_compliment is set to true, at which point, they're\n     * saved as two's compliment.\n     *\n     * Here's an example:\n     * <code>\n     * <?php\n     *    include('Math/BigInteger.php');\n     *\n     *    $a = new Math_BigInteger('65');\n     *\n     *    echo $a->toHex(); // outputs '41'\n     * ?>\n     * </code>\n     *\n     * @param Boolean $twos_compliment\n     * @return String\n     * @access public\n     * @internal Converts a base-2**26 number to base-2**8\n     */\n    function toHex($twos_compliment = false)\n    {\n        return bin2hex($this->toBytes($twos_compliment));\n    }\n\n    /**\n     * Converts a BigInteger to a bit string (eg. base-2).\n     *\n     * Negative numbers are saved as positive numbers, unless $twos_compliment is set to true, at which point, they're\n     * saved as two's compliment.\n     *\n     * Here's an example:\n     * <code>\n     * <?php\n     *    include('Math/BigInteger.php');\n     *\n     *    $a = new Math_BigInteger('65');\n     *\n     *    echo $a->toBits(); // outputs '1000001'\n     * ?>\n     * </code>\n     *\n     * @param Boolean $twos_compliment\n     * @return String\n     * @access public\n     * @internal Converts a base-2**26 number to base-2**2\n     */\n    function toBits($twos_compliment = false)\n    {\n        $hex = $this->toHex($twos_compliment);\n        $bits = '';\n        for ($i = strlen($hex) - 8, $start = strlen($hex) & 7; $i >= $start; $i-=8) {\n            $bits = str_pad(decbin(hexdec(substr($hex, $i, 8))), 32, '0', STR_PAD_LEFT) . $bits;\n        }\n        if ($start) { // hexdec('') == 0\n            $bits = str_pad(decbin(hexdec(substr($hex, 0, $start))), 8, '0', STR_PAD_LEFT) . $bits;\n        }\n        $result = $this->precision > 0 ? substr($bits, -$this->precision) : ltrim($bits, '0');\n\n        if ($twos_compliment && $this->compare(new Math_BigInteger()) > 0 && $this->precision <= 0) {\n            return '0' . $result;\n        }\n\n        return $result;\n    }\n\n    /**\n     * Converts a BigInteger to a base-10 number.\n     *\n     * Here's an example:\n     * <code>\n     * <?php\n     *    include('Math/BigInteger.php');\n     *\n     *    $a = new Math_BigInteger('50');\n     *\n     *    echo $a->toString(); // outputs 50\n     * ?>\n     * </code>\n     *\n     * @return String\n     * @access public\n     * @internal Converts a base-2**26 number to base-10**7 (which is pretty much base-10)\n     */\n    function toString()\n    {\n        switch ( MATH_BIGINTEGER_MODE ) {\n            case MATH_BIGINTEGER_MODE_GMP:\n                return gmp_strval($this->value);\n            case MATH_BIGINTEGER_MODE_BCMATH:\n                if ($this->value === '0') {\n                    return '0';\n                }\n\n                return ltrim($this->value, '0');\n        }\n\n        if (!count($this->value)) {\n            return '0';\n        }\n\n        $temp = $this->copy();\n        $temp->is_negative = false;\n\n        $divisor = new Math_BigInteger();\n        $divisor->value = array(MATH_BIGINTEGER_MAX10);\n        $result = '';\n        while (count($temp->value)) {\n            list($temp, $mod) = $temp->divide($divisor);\n            $result = str_pad(isset($mod->value[0]) ? $mod->value[0] : '', MATH_BIGINTEGER_MAX10_LEN, '0', STR_PAD_LEFT) . $result;\n        }\n        $result = ltrim($result, '0');\n        if (empty($result)) {\n            $result = '0';\n        }\n\n        if ($this->is_negative) {\n            $result = '-' . $result;\n        }\n\n        return $result;\n    }\n\n    /**\n     * Copy an object\n     *\n     * PHP5 passes objects by reference while PHP4 passes by value.  As such, we need a function to guarantee\n     * that all objects are passed by value, when appropriate.  More information can be found here:\n     *\n     * {@link http://php.net/language.oop5.basic#51624}\n     *\n     * @access public\n     * @see __clone()\n     * @return Math_BigInteger\n     */\n    function copy()\n    {\n        $temp = new Math_BigInteger();\n        $temp->value = $this->value;\n        $temp->is_negative = $this->is_negative;\n        $temp->generator = $this->generator;\n        $temp->precision = $this->precision;\n        $temp->bitmask = $this->bitmask;\n        return $temp;\n    }\n\n    /**\n     *  __toString() magic method\n     *\n     * Will be called, automatically, if you're supporting just PHP5.  If you're supporting PHP4, you'll need to call\n     * toString().\n     *\n     * @access public\n     * @internal Implemented per a suggestion by Techie-Michael - thanks!\n     */\n    function __toString()\n    {\n        return $this->toString();\n    }\n\n    /**\n     * __clone() magic method\n     *\n     * Although you can call Math_BigInteger::__toString() directly in PHP5, you cannot call Math_BigInteger::__clone()\n     * directly in PHP5.  You can in PHP4 since it's not a magic method, but in PHP5, you have to call it by using the PHP5\n     * only syntax of $y = clone $x.  As such, if you're trying to write an application that works on both PHP4 and PHP5,\n     * call Math_BigInteger::copy(), instead.\n     *\n     * @access public\n     * @see copy()\n     * @return Math_BigInteger\n     */\n    function __clone()\n    {\n        return $this->copy();\n    }\n\n    /**\n     *  __sleep() magic method\n     *\n     * Will be called, automatically, when serialize() is called on a Math_BigInteger object.\n     *\n     * @see __wakeup()\n     * @access public\n     */\n    function __sleep()\n    {\n        $this->hex = $this->toHex(true);\n        $vars = array('hex');\n        if ($this->generator != 'mt_rand') {\n            $vars[] = 'generator';\n        }\n        if ($this->precision > 0) {\n            $vars[] = 'precision';\n        }\n        return $vars;\n\n    }\n\n    /**\n     *  __wakeup() magic method\n     *\n     * Will be called, automatically, when unserialize() is called on a Math_BigInteger object.\n     *\n     * @see __sleep()\n     * @access public\n     */\n    function __wakeup()\n    {\n        $temp = new Math_BigInteger($this->hex, -16);\n        $this->value = $temp->value;\n        $this->is_negative = $temp->is_negative;\n        $this->setRandomGenerator($this->generator);\n        if ($this->precision > 0) {\n            // recalculate $this->bitmask\n            $this->setPrecision($this->precision);\n        }\n    }\n\n    /**\n     * Adds two BigIntegers.\n     *\n     * Here's an example:\n     * <code>\n     * <?php\n     *    include('Math/BigInteger.php');\n     *\n     *    $a = new Math_BigInteger('10');\n     *    $b = new Math_BigInteger('20');\n     *\n     *    $c = $a->add($b);\n     *\n     *    echo $c->toString(); // outputs 30\n     * ?>\n     * </code>\n     *\n     * @param Math_BigInteger $y\n     * @return Math_BigInteger\n     * @access public\n     * @internal Performs base-2**52 addition\n     */\n    function add($y)\n    {\n        switch ( MATH_BIGINTEGER_MODE ) {\n            case MATH_BIGINTEGER_MODE_GMP:\n                $temp = new Math_BigInteger();\n                $temp->value = gmp_add($this->value, $y->value);\n\n                return $this->_normalize($temp);\n            case MATH_BIGINTEGER_MODE_BCMATH:\n                $temp = new Math_BigInteger();\n                $temp->value = bcadd($this->value, $y->value, 0);\n\n                return $this->_normalize($temp);\n        }\n\n        $temp = $this->_add($this->value, $this->is_negative, $y->value, $y->is_negative);\n\n        $result = new Math_BigInteger();\n        $result->value = $temp[MATH_BIGINTEGER_VALUE];\n        $result->is_negative = $temp[MATH_BIGINTEGER_SIGN];\n\n        return $this->_normalize($result);\n    }\n\n    /**\n     * Performs addition.\n     *\n     * @param Array $x_value\n     * @param Boolean $x_negative\n     * @param Array $y_value\n     * @param Boolean $y_negative\n     * @return Array\n     * @access private\n     */\n    function _add($x_value, $x_negative, $y_value, $y_negative)\n    {\n        $x_size = count($x_value);\n        $y_size = count($y_value);\n\n        if ($x_size == 0) {\n            return array(\n                MATH_BIGINTEGER_VALUE => $y_value,\n                MATH_BIGINTEGER_SIGN => $y_negative\n            );\n        } else if ($y_size == 0) {\n            return array(\n                MATH_BIGINTEGER_VALUE => $x_value,\n                MATH_BIGINTEGER_SIGN => $x_negative\n            );\n        }\n\n        // subtract, if appropriate\n        if ( $x_negative != $y_negative ) {\n            if ( $x_value == $y_value ) {\n                return array(\n                    MATH_BIGINTEGER_VALUE => array(),\n                    MATH_BIGINTEGER_SIGN => false\n                );\n            }\n\n            $temp = $this->_subtract($x_value, false, $y_value, false);\n            $temp[MATH_BIGINTEGER_SIGN] = $this->_compare($x_value, false, $y_value, false) > 0 ?\n                                          $x_negative : $y_negative;\n\n            return $temp;\n        }\n\n        if ($x_size < $y_size) {\n            $size = $x_size;\n            $value = $y_value;\n        } else {\n            $size = $y_size;\n            $value = $x_value;\n        }\n\n        $value[] = 0; // just in case the carry adds an extra digit\n\n        $carry = 0;\n        for ($i = 0, $j = 1; $j < $size; $i+=2, $j+=2) {\n            $sum = $x_value[$j] * MATH_BIGINTEGER_BASE_FULL + $x_value[$i] + $y_value[$j] * MATH_BIGINTEGER_BASE_FULL + $y_value[$i] + $carry;\n            $carry = $sum >= MATH_BIGINTEGER_MAX_DIGIT2; // eg. floor($sum / 2**52); only possible values (in any base) are 0 and 1\n            $sum = $carry ? $sum - MATH_BIGINTEGER_MAX_DIGIT2 : $sum;\n\n            $temp = (int) ($sum / MATH_BIGINTEGER_BASE_FULL);\n\n            $value[$i] = (int) ($sum - MATH_BIGINTEGER_BASE_FULL * $temp); // eg. a faster alternative to fmod($sum, 0x4000000)\n            $value[$j] = $temp;\n        }\n\n        if ($j == $size) { // ie. if $y_size is odd\n            $sum = $x_value[$i] + $y_value[$i] + $carry;\n            $carry = $sum >= MATH_BIGINTEGER_BASE_FULL;\n            $value[$i] = $carry ? $sum - MATH_BIGINTEGER_BASE_FULL : $sum;\n            ++$i; // ie. let $i = $j since we've just done $value[$i]\n        }\n\n        if ($carry) {\n            for (; $value[$i] == MATH_BIGINTEGER_MAX_DIGIT; ++$i) {\n                $value[$i] = 0;\n            }\n            ++$value[$i];\n        }\n\n        return array(\n            MATH_BIGINTEGER_VALUE => $this->_trim($value),\n            MATH_BIGINTEGER_SIGN => $x_negative\n        );\n    }\n\n    /**\n     * Subtracts two BigIntegers.\n     *\n     * Here's an example:\n     * <code>\n     * <?php\n     *    include('Math/BigInteger.php');\n     *\n     *    $a = new Math_BigInteger('10');\n     *    $b = new Math_BigInteger('20');\n     *\n     *    $c = $a->subtract($b);\n     *\n     *    echo $c->toString(); // outputs -10\n     * ?>\n     * </code>\n     *\n     * @param Math_BigInteger $y\n     * @return Math_BigInteger\n     * @access public\n     * @internal Performs base-2**52 subtraction\n     */\n    function subtract($y)\n    {\n        switch ( MATH_BIGINTEGER_MODE ) {\n            case MATH_BIGINTEGER_MODE_GMP:\n                $temp = new Math_BigInteger();\n                $temp->value = gmp_sub($this->value, $y->value);\n\n                return $this->_normalize($temp);\n            case MATH_BIGINTEGER_MODE_BCMATH:\n                $temp = new Math_BigInteger();\n                $temp->value = bcsub($this->value, $y->value, 0);\n\n                return $this->_normalize($temp);\n        }\n\n        $temp = $this->_subtract($this->value, $this->is_negative, $y->value, $y->is_negative);\n\n        $result = new Math_BigInteger();\n        $result->value = $temp[MATH_BIGINTEGER_VALUE];\n        $result->is_negative = $temp[MATH_BIGINTEGER_SIGN];\n\n        return $this->_normalize($result);\n    }\n\n    /**\n     * Performs subtraction.\n     *\n     * @param Array $x_value\n     * @param Boolean $x_negative\n     * @param Array $y_value\n     * @param Boolean $y_negative\n     * @return Array\n     * @access private\n     */\n    function _subtract($x_value, $x_negative, $y_value, $y_negative)\n    {\n        $x_size = count($x_value);\n        $y_size = count($y_value);\n\n        if ($x_size == 0) {\n            return array(\n                MATH_BIGINTEGER_VALUE => $y_value,\n                MATH_BIGINTEGER_SIGN => !$y_negative\n            );\n        } else if ($y_size == 0) {\n            return array(\n                MATH_BIGINTEGER_VALUE => $x_value,\n                MATH_BIGINTEGER_SIGN => $x_negative\n            );\n        }\n\n        // add, if appropriate (ie. -$x - +$y or +$x - -$y)\n        if ( $x_negative != $y_negative ) {\n            $temp = $this->_add($x_value, false, $y_value, false);\n            $temp[MATH_BIGINTEGER_SIGN] = $x_negative;\n\n            return $temp;\n        }\n\n        $diff = $this->_compare($x_value, $x_negative, $y_value, $y_negative);\n\n        if ( !$diff ) {\n            return array(\n                MATH_BIGINTEGER_VALUE => array(),\n                MATH_BIGINTEGER_SIGN => false\n            );\n        }\n\n        // switch $x and $y around, if appropriate.\n        if ( (!$x_negative && $diff < 0) || ($x_negative && $diff > 0) ) {\n            $temp = $x_value;\n            $x_value = $y_value;\n            $y_value = $temp;\n\n            $x_negative = !$x_negative;\n\n            $x_size = count($x_value);\n            $y_size = count($y_value);\n        }\n\n        // at this point, $x_value should be at least as big as - if not bigger than - $y_value\n\n        $carry = 0;\n        for ($i = 0, $j = 1; $j < $y_size; $i+=2, $j+=2) {\n            $sum = $x_value[$j] * MATH_BIGINTEGER_BASE_FULL + $x_value[$i] - $y_value[$j] * MATH_BIGINTEGER_BASE_FULL - $y_value[$i] - $carry;\n            $carry = $sum < 0; // eg. floor($sum / 2**52); only possible values (in any base) are 0 and 1\n            $sum = $carry ? $sum + MATH_BIGINTEGER_MAX_DIGIT2 : $sum;\n\n            $temp = (int) ($sum / MATH_BIGINTEGER_BASE_FULL);\n\n            $x_value[$i] = (int) ($sum - MATH_BIGINTEGER_BASE_FULL * $temp);\n            $x_value[$j] = $temp;\n        }\n\n        if ($j == $y_size) { // ie. if $y_size is odd\n            $sum = $x_value[$i] - $y_value[$i] - $carry;\n            $carry = $sum < 0;\n            $x_value[$i] = $carry ? $sum + MATH_BIGINTEGER_BASE_FULL : $sum;\n            ++$i;\n        }\n\n        if ($carry) {\n            for (; !$x_value[$i]; ++$i) {\n                $x_value[$i] = MATH_BIGINTEGER_MAX_DIGIT;\n            }\n            --$x_value[$i];\n        }\n\n        return array(\n            MATH_BIGINTEGER_VALUE => $this->_trim($x_value),\n            MATH_BIGINTEGER_SIGN => $x_negative\n        );\n    }\n\n    /**\n     * Multiplies two BigIntegers\n     *\n     * Here's an example:\n     * <code>\n     * <?php\n     *    include('Math/BigInteger.php');\n     *\n     *    $a = new Math_BigInteger('10');\n     *    $b = new Math_BigInteger('20');\n     *\n     *    $c = $a->multiply($b);\n     *\n     *    echo $c->toString(); // outputs 200\n     * ?>\n     * </code>\n     *\n     * @param Math_BigInteger $x\n     * @return Math_BigInteger\n     * @access public\n     */\n    function multiply($x)\n    {\n        switch ( MATH_BIGINTEGER_MODE ) {\n            case MATH_BIGINTEGER_MODE_GMP:\n                $temp = new Math_BigInteger();\n                $temp->value = gmp_mul($this->value, $x->value);\n\n                return $this->_normalize($temp);\n            case MATH_BIGINTEGER_MODE_BCMATH:\n                $temp = new Math_BigInteger();\n                $temp->value = bcmul($this->value, $x->value, 0);\n\n                return $this->_normalize($temp);\n        }\n\n        $temp = $this->_multiply($this->value, $this->is_negative, $x->value, $x->is_negative);\n\n        $product = new Math_BigInteger();\n        $product->value = $temp[MATH_BIGINTEGER_VALUE];\n        $product->is_negative = $temp[MATH_BIGINTEGER_SIGN];\n\n        return $this->_normalize($product);\n    }\n\n    /**\n     * Performs multiplication.\n     *\n     * @param Array $x_value\n     * @param Boolean $x_negative\n     * @param Array $y_value\n     * @param Boolean $y_negative\n     * @return Array\n     * @access private\n     */\n    function _multiply($x_value, $x_negative, $y_value, $y_negative)\n    {\n        //if ( $x_value == $y_value ) {\n        //    return array(\n        //        MATH_BIGINTEGER_VALUE => $this->_square($x_value),\n        //        MATH_BIGINTEGER_SIGN => $x_sign != $y_value\n        //    );\n        //}\n\n        $x_length = count($x_value);\n        $y_length = count($y_value);\n\n        if ( !$x_length || !$y_length ) { // a 0 is being multiplied\n            return array(\n                MATH_BIGINTEGER_VALUE => array(),\n                MATH_BIGINTEGER_SIGN => false\n            );\n        }\n\n        return array(\n            MATH_BIGINTEGER_VALUE => min($x_length, $y_length) < 2 * MATH_BIGINTEGER_KARATSUBA_CUTOFF ?\n                $this->_trim($this->_regularMultiply($x_value, $y_value)) :\n                $this->_trim($this->_karatsuba($x_value, $y_value)),\n            MATH_BIGINTEGER_SIGN => $x_negative != $y_negative\n        );\n    }\n\n    /**\n     * Performs long multiplication on two BigIntegers\n     *\n     * Modeled after 'multiply' in MutableBigInteger.java.\n     *\n     * @param Array $x_value\n     * @param Array $y_value\n     * @return Array\n     * @access private\n     */\n    function _regularMultiply($x_value, $y_value)\n    {\n        $x_length = count($x_value);\n        $y_length = count($y_value);\n\n        if ( !$x_length || !$y_length ) { // a 0 is being multiplied\n            return array();\n        }\n\n        if ( $x_length < $y_length ) {\n            $temp = $x_value;\n            $x_value = $y_value;\n            $y_value = $temp;\n\n            $x_length = count($x_value);\n            $y_length = count($y_value);\n        }\n\n        $product_value = $this->_array_repeat(0, $x_length + $y_length);\n\n        // the following for loop could be removed if the for loop following it\n        // (the one with nested for loops) initially set $i to 0, but\n        // doing so would also make the result in one set of unnecessary adds,\n        // since on the outermost loops first pass, $product->value[$k] is going\n        // to always be 0\n\n        $carry = 0;\n\n        for ($j = 0; $j < $x_length; ++$j) { // ie. $i = 0\n            $temp = $x_value[$j] * $y_value[0] + $carry; // $product_value[$k] == 0\n            $carry = (int) ($temp / MATH_BIGINTEGER_BASE_FULL);\n            $product_value[$j] = (int) ($temp - MATH_BIGINTEGER_BASE_FULL * $carry);\n        }\n\n        $product_value[$j] = $carry;\n\n        // the above for loop is what the previous comment was talking about.  the\n        // following for loop is the \"one with nested for loops\"\n        for ($i = 1; $i < $y_length; ++$i) {\n            $carry = 0;\n\n            for ($j = 0, $k = $i; $j < $x_length; ++$j, ++$k) {\n                $temp = $product_value[$k] + $x_value[$j] * $y_value[$i] + $carry;\n                $carry = (int) ($temp / MATH_BIGINTEGER_BASE_FULL);\n                $product_value[$k] = (int) ($temp - MATH_BIGINTEGER_BASE_FULL * $carry);\n            }\n\n            $product_value[$k] = $carry;\n        }\n\n        return $product_value;\n    }\n\n    /**\n     * Performs Karatsuba multiplication on two BigIntegers\n     *\n     * See {@link http://en.wikipedia.org/wiki/Karatsuba_algorithm Karatsuba algorithm} and\n     * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=120 MPM 5.2.3}.\n     *\n     * @param Array $x_value\n     * @param Array $y_value\n     * @return Array\n     * @access private\n     */\n    function _karatsuba($x_value, $y_value)\n    {\n        $m = min(count($x_value) >> 1, count($y_value) >> 1);\n\n        if ($m < MATH_BIGINTEGER_KARATSUBA_CUTOFF) {\n            return $this->_regularMultiply($x_value, $y_value);\n        }\n\n        $x1 = array_slice($x_value, $m);\n        $x0 = array_slice($x_value, 0, $m);\n        $y1 = array_slice($y_value, $m);\n        $y0 = array_slice($y_value, 0, $m);\n\n        $z2 = $this->_karatsuba($x1, $y1);\n        $z0 = $this->_karatsuba($x0, $y0);\n\n        $z1 = $this->_add($x1, false, $x0, false);\n        $temp = $this->_add($y1, false, $y0, false);\n        $z1 = $this->_karatsuba($z1[MATH_BIGINTEGER_VALUE], $temp[MATH_BIGINTEGER_VALUE]);\n        $temp = $this->_add($z2, false, $z0, false);\n        $z1 = $this->_subtract($z1, false, $temp[MATH_BIGINTEGER_VALUE], false);\n\n        $z2 = array_merge(array_fill(0, 2 * $m, 0), $z2);\n        $z1[MATH_BIGINTEGER_VALUE] = array_merge(array_fill(0, $m, 0), $z1[MATH_BIGINTEGER_VALUE]);\n\n        $xy = $this->_add($z2, false, $z1[MATH_BIGINTEGER_VALUE], $z1[MATH_BIGINTEGER_SIGN]);\n        $xy = $this->_add($xy[MATH_BIGINTEGER_VALUE], $xy[MATH_BIGINTEGER_SIGN], $z0, false);\n\n        return $xy[MATH_BIGINTEGER_VALUE];\n    }\n\n    /**\n     * Performs squaring\n     *\n     * @param Array $x\n     * @return Array\n     * @access private\n     */\n    function _square($x = false)\n    {\n        return count($x) < 2 * MATH_BIGINTEGER_KARATSUBA_CUTOFF ?\n            $this->_trim($this->_baseSquare($x)) :\n            $this->_trim($this->_karatsubaSquare($x));\n    }\n\n    /**\n     * Performs traditional squaring on two BigIntegers\n     *\n     * Squaring can be done faster than multiplying a number by itself can be.  See\n     * {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=7 HAC 14.2.4} /\n     * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=141 MPM 5.3} for more information.\n     *\n     * @param Array $value\n     * @return Array\n     * @access private\n     */\n    function _baseSquare($value)\n    {\n        if ( empty($value) ) {\n            return array();\n        }\n        $square_value = $this->_array_repeat(0, 2 * count($value));\n\n        for ($i = 0, $max_index = count($value) - 1; $i <= $max_index; ++$i) {\n            $i2 = $i << 1;\n\n            $temp = $square_value[$i2] + $value[$i] * $value[$i];\n            $carry = (int) ($temp / MATH_BIGINTEGER_BASE_FULL);\n            $square_value[$i2] = (int) ($temp - MATH_BIGINTEGER_BASE_FULL * $carry);\n\n            // note how we start from $i+1 instead of 0 as we do in multiplication.\n            for ($j = $i + 1, $k = $i2 + 1; $j <= $max_index; ++$j, ++$k) {\n                $temp = $square_value[$k] + 2 * $value[$j] * $value[$i] + $carry;\n                $carry = (int) ($temp / MATH_BIGINTEGER_BASE_FULL);\n                $square_value[$k] = (int) ($temp - MATH_BIGINTEGER_BASE_FULL * $carry);\n            }\n\n            // the following line can yield values larger 2**15.  at this point, PHP should switch\n            // over to floats.\n            $square_value[$i + $max_index + 1] = $carry;\n        }\n\n        return $square_value;\n    }\n\n    /**\n     * Performs Karatsuba \"squaring\" on two BigIntegers\n     *\n     * See {@link http://en.wikipedia.org/wiki/Karatsuba_algorithm Karatsuba algorithm} and\n     * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=151 MPM 5.3.4}.\n     *\n     * @param Array $value\n     * @return Array\n     * @access private\n     */\n    function _karatsubaSquare($value)\n    {\n        $m = count($value) >> 1;\n\n        if ($m < MATH_BIGINTEGER_KARATSUBA_CUTOFF) {\n            return $this->_baseSquare($value);\n        }\n\n        $x1 = array_slice($value, $m);\n        $x0 = array_slice($value, 0, $m);\n\n        $z2 = $this->_karatsubaSquare($x1);\n        $z0 = $this->_karatsubaSquare($x0);\n\n        $z1 = $this->_add($x1, false, $x0, false);\n        $z1 = $this->_karatsubaSquare($z1[MATH_BIGINTEGER_VALUE]);\n        $temp = $this->_add($z2, false, $z0, false);\n        $z1 = $this->_subtract($z1, false, $temp[MATH_BIGINTEGER_VALUE], false);\n\n        $z2 = array_merge(array_fill(0, 2 * $m, 0), $z2);\n        $z1[MATH_BIGINTEGER_VALUE] = array_merge(array_fill(0, $m, 0), $z1[MATH_BIGINTEGER_VALUE]);\n\n        $xx = $this->_add($z2, false, $z1[MATH_BIGINTEGER_VALUE], $z1[MATH_BIGINTEGER_SIGN]);\n        $xx = $this->_add($xx[MATH_BIGINTEGER_VALUE], $xx[MATH_BIGINTEGER_SIGN], $z0, false);\n\n        return $xx[MATH_BIGINTEGER_VALUE];\n    }\n\n    /**\n     * Divides two BigIntegers.\n     *\n     * Returns an array whose first element contains the quotient and whose second element contains the\n     * \"common residue\".  If the remainder would be positive, the \"common residue\" and the remainder are the\n     * same.  If the remainder would be negative, the \"common residue\" is equal to the sum of the remainder\n     * and the divisor (basically, the \"common residue\" is the first positive modulo).\n     *\n     * Here's an example:\n     * <code>\n     * <?php\n     *    include('Math/BigInteger.php');\n     *\n     *    $a = new Math_BigInteger('10');\n     *    $b = new Math_BigInteger('20');\n     *\n     *    list($quotient, $remainder) = $a->divide($b);\n     *\n     *    echo $quotient->toString(); // outputs 0\n     *    echo \"\\r\\n\";\n     *    echo $remainder->toString(); // outputs 10\n     * ?>\n     * </code>\n     *\n     * @param Math_BigInteger $y\n     * @return Array\n     * @access public\n     * @internal This function is based off of {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=9 HAC 14.20}.\n     */\n    function divide($y)\n    {\n        switch ( MATH_BIGINTEGER_MODE ) {\n            case MATH_BIGINTEGER_MODE_GMP:\n                $quotient = new Math_BigInteger();\n                $remainder = new Math_BigInteger();\n\n                list($quotient->value, $remainder->value) = gmp_div_qr($this->value, $y->value);\n\n                if (gmp_sign($remainder->value) < 0) {\n                    $remainder->value = gmp_add($remainder->value, gmp_abs($y->value));\n                }\n\n                return array($this->_normalize($quotient), $this->_normalize($remainder));\n            case MATH_BIGINTEGER_MODE_BCMATH:\n                $quotient = new Math_BigInteger();\n                $remainder = new Math_BigInteger();\n\n                $quotient->value = bcdiv($this->value, $y->value, 0);\n                $remainder->value = bcmod($this->value, $y->value);\n\n                if ($remainder->value[0] == '-') {\n                    $remainder->value = bcadd($remainder->value, $y->value[0] == '-' ? substr($y->value, 1) : $y->value, 0);\n                }\n\n                return array($this->_normalize($quotient), $this->_normalize($remainder));\n        }\n\n        if (count($y->value) == 1) {\n            list($q, $r) = $this->_divide_digit($this->value, $y->value[0]);\n            $quotient = new Math_BigInteger();\n            $remainder = new Math_BigInteger();\n            $quotient->value = $q;\n            $remainder->value = array($r);\n            $quotient->is_negative = $this->is_negative != $y->is_negative;\n            return array($this->_normalize($quotient), $this->_normalize($remainder));\n        }\n\n        static $zero;\n        if ( !isset($zero) ) {\n            $zero = new Math_BigInteger();\n        }\n\n        $x = $this->copy();\n        $y = $y->copy();\n\n        $x_sign = $x->is_negative;\n        $y_sign = $y->is_negative;\n\n        $x->is_negative = $y->is_negative = false;\n\n        $diff = $x->compare($y);\n\n        if ( !$diff ) {\n            $temp = new Math_BigInteger();\n            $temp->value = array(1);\n            $temp->is_negative = $x_sign != $y_sign;\n            return array($this->_normalize($temp), $this->_normalize(new Math_BigInteger()));\n        }\n\n        if ( $diff < 0 ) {\n            // if $x is negative, \"add\" $y.\n            if ( $x_sign ) {\n                $x = $y->subtract($x);\n            }\n            return array($this->_normalize(new Math_BigInteger()), $this->_normalize($x));\n        }\n\n        // normalize $x and $y as described in HAC 14.23 / 14.24\n        $msb = $y->value[count($y->value) - 1];\n        for ($shift = 0; !($msb & MATH_BIGINTEGER_MSB); ++$shift) {\n            $msb <<= 1;\n        }\n        $x->_lshift($shift);\n        $y->_lshift($shift);\n        $y_value = &$y->value;\n\n        $x_max = count($x->value) - 1;\n        $y_max = count($y->value) - 1;\n\n        $quotient = new Math_BigInteger();\n        $quotient_value = &$quotient->value;\n        $quotient_value = $this->_array_repeat(0, $x_max - $y_max + 1);\n\n        static $temp, $lhs, $rhs;\n        if (!isset($temp)) {\n            $temp = new Math_BigInteger();\n            $lhs =  new Math_BigInteger();\n            $rhs =  new Math_BigInteger();\n        }\n        $temp_value = &$temp->value;\n        $rhs_value =  &$rhs->value;\n\n        // $temp = $y << ($x_max - $y_max-1) in base 2**26\n        $temp_value = array_merge($this->_array_repeat(0, $x_max - $y_max), $y_value);\n\n        while ( $x->compare($temp) >= 0 ) {\n            // calculate the \"common residue\"\n            ++$quotient_value[$x_max - $y_max];\n            $x = $x->subtract($temp);\n            $x_max = count($x->value) - 1;\n        }\n\n        for ($i = $x_max; $i >= $y_max + 1; --$i) {\n            $x_value = &$x->value;\n            $x_window = array(\n                isset($x_value[$i]) ? $x_value[$i] : 0,\n                isset($x_value[$i - 1]) ? $x_value[$i - 1] : 0,\n                isset($x_value[$i - 2]) ? $x_value[$i - 2] : 0\n            );\n            $y_window = array(\n                $y_value[$y_max],\n                ( $y_max > 0 ) ? $y_value[$y_max - 1] : 0\n            );\n\n            $q_index = $i - $y_max - 1;\n            if ($x_window[0] == $y_window[0]) {\n                $quotient_value[$q_index] = MATH_BIGINTEGER_MAX_DIGIT;\n            } else {\n                $quotient_value[$q_index] = (int) (\n                    ($x_window[0] * MATH_BIGINTEGER_BASE_FULL + $x_window[1])\n                    /\n                    $y_window[0]\n                );\n            }\n\n            $temp_value = array($y_window[1], $y_window[0]);\n\n            $lhs->value = array($quotient_value[$q_index]);\n            $lhs = $lhs->multiply($temp);\n\n            $rhs_value = array($x_window[2], $x_window[1], $x_window[0]);\n\n            while ( $lhs->compare($rhs) > 0 ) {\n                --$quotient_value[$q_index];\n\n                $lhs->value = array($quotient_value[$q_index]);\n                $lhs = $lhs->multiply($temp);\n            }\n\n            $adjust = $this->_array_repeat(0, $q_index);\n            $temp_value = array($quotient_value[$q_index]);\n            $temp = $temp->multiply($y);\n            $temp_value = &$temp->value;\n            $temp_value = array_merge($adjust, $temp_value);\n\n            $x = $x->subtract($temp);\n\n            if ($x->compare($zero) < 0) {\n                $temp_value = array_merge($adjust, $y_value);\n                $x = $x->add($temp);\n\n                --$quotient_value[$q_index];\n            }\n\n            $x_max = count($x_value) - 1;\n        }\n\n        // unnormalize the remainder\n        $x->_rshift($shift);\n\n        $quotient->is_negative = $x_sign != $y_sign;\n\n        // calculate the \"common residue\", if appropriate\n        if ( $x_sign ) {\n            $y->_rshift($shift);\n            $x = $y->subtract($x);\n        }\n\n        return array($this->_normalize($quotient), $this->_normalize($x));\n    }\n\n    /**\n     * Divides a BigInteger by a regular integer\n     *\n     * abc / x = a00 / x + b0 / x + c / x\n     *\n     * @param Array $dividend\n     * @param Array $divisor\n     * @return Array\n     * @access private\n     */\n    function _divide_digit($dividend, $divisor)\n    {\n        $carry = 0;\n        $result = array();\n\n        for ($i = count($dividend) - 1; $i >= 0; --$i) {\n            $temp = MATH_BIGINTEGER_BASE_FULL * $carry + $dividend[$i];\n            $result[$i] = (int) ($temp / $divisor);\n            $carry = (int) ($temp - $divisor * $result[$i]);\n        }\n\n        return array($result, $carry);\n    }\n\n    /**\n     * Performs modular exponentiation.\n     *\n     * Here's an example:\n     * <code>\n     * <?php\n     *    include('Math/BigInteger.php');\n     *\n     *    $a = new Math_BigInteger('10');\n     *    $b = new Math_BigInteger('20');\n     *    $c = new Math_BigInteger('30');\n     *\n     *    $c = $a->modPow($b, $c);\n     *\n     *    echo $c->toString(); // outputs 10\n     * ?>\n     * </code>\n     *\n     * @param Math_BigInteger $e\n     * @param Math_BigInteger $n\n     * @return Math_BigInteger\n     * @access public\n     * @internal The most naive approach to modular exponentiation has very unreasonable requirements, and\n     *    and although the approach involving repeated squaring does vastly better, it, too, is impractical\n     *    for our purposes.  The reason being that division - by far the most complicated and time-consuming\n     *    of the basic operations (eg. +,-,*,/) - occurs multiple times within it.\n     *\n     *    Modular reductions resolve this issue.  Although an individual modular reduction takes more time\n     *    then an individual division, when performed in succession (with the same modulo), they're a lot faster.\n     *\n     *    The two most commonly used modular reductions are Barrett and Montgomery reduction.  Montgomery reduction,\n     *    although faster, only works when the gcd of the modulo and of the base being used is 1.  In RSA, when the\n     *    base is a power of two, the modulo - a product of two primes - is always going to have a gcd of 1 (because\n     *    the product of two odd numbers is odd), but what about when RSA isn't used?\n     *\n     *    In contrast, Barrett reduction has no such constraint.  As such, some bigint implementations perform a\n     *    Barrett reduction after every operation in the modpow function.  Others perform Barrett reductions when the\n     *    modulo is even and Montgomery reductions when the modulo is odd.  BigInteger.java's modPow method, however,\n     *    uses a trick involving the Chinese Remainder Theorem to factor the even modulo into two numbers - one odd and\n     *    the other, a power of two - and recombine them, later.  This is the method that this modPow function uses.\n     *    {@link http://islab.oregonstate.edu/papers/j34monex.pdf Montgomery Reduction with Even Modulus} elaborates.\n     */\n    function modPow($e, $n)\n    {\n        $n = $this->bitmask !== false && $this->bitmask->compare($n) < 0 ? $this->bitmask : $n->abs();\n\n        if ($e->compare(new Math_BigInteger()) < 0) {\n            $e = $e->abs();\n\n            $temp = $this->modInverse($n);\n            if ($temp === false) {\n                return false;\n            }\n\n            return $this->_normalize($temp->modPow($e, $n));\n        }\n\n        if ( MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_GMP ) {\n            $temp = new Math_BigInteger();\n            $temp->value = gmp_powm($this->value, $e->value, $n->value);\n\n            return $this->_normalize($temp);\n        }\n\n        if ($this->compare(new Math_BigInteger()) < 0 || $this->compare($n) > 0) {\n            list(, $temp) = $this->divide($n);\n            return $temp->modPow($e, $n);\n        }\n\n        if (defined('MATH_BIGINTEGER_OPENSSL_ENABLED')) {\n            $components = array(\n                'modulus' => $n->toBytes(true),\n                'publicExponent' => $e->toBytes(true)\n            );\n\n            $components = array(\n                'modulus' => pack('Ca*a*', 2, $this->_encodeASN1Length(strlen($components['modulus'])), $components['modulus']),\n                'publicExponent' => pack('Ca*a*', 2, $this->_encodeASN1Length(strlen($components['publicExponent'])), $components['publicExponent'])\n            );\n\n            $RSAPublicKey = pack('Ca*a*a*',\n                48, $this->_encodeASN1Length(strlen($components['modulus']) + strlen($components['publicExponent'])),\n                $components['modulus'], $components['publicExponent']\n            );\n\n            $rsaOID = pack('H*', '300d06092a864886f70d0101010500'); // hex version of MA0GCSqGSIb3DQEBAQUA\n            $RSAPublicKey = chr(0) . $RSAPublicKey;\n            $RSAPublicKey = chr(3) . $this->_encodeASN1Length(strlen($RSAPublicKey)) . $RSAPublicKey;\n\n            $encapsulated = pack('Ca*a*',\n                48, $this->_encodeASN1Length(strlen($rsaOID . $RSAPublicKey)), $rsaOID . $RSAPublicKey\n            );\n\n            $RSAPublicKey = \"-----BEGIN PUBLIC KEY-----\\r\\n\" .\n                             chunk_split(base64_encode($encapsulated)) .\n                             '-----END PUBLIC KEY-----';\n\n            $plaintext = str_pad($this->toBytes(), strlen($n->toBytes(true)) - 1, \"\\0\", STR_PAD_LEFT);\n\n            if (openssl_public_encrypt($plaintext, $result, $RSAPublicKey, OPENSSL_NO_PADDING)) {\n                return new Math_BigInteger($result, 256);\n            }\n        }\n\n        if ( MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_BCMATH ) {\n                $temp = new Math_BigInteger();\n                $temp->value = bcpowmod($this->value, $e->value, $n->value, 0);\n\n                return $this->_normalize($temp);\n        }\n\n        if ( empty($e->value) ) {\n            $temp = new Math_BigInteger();\n            $temp->value = array(1);\n            return $this->_normalize($temp);\n        }\n\n        if ( $e->value == array(1) ) {\n            list(, $temp) = $this->divide($n);\n            return $this->_normalize($temp);\n        }\n\n        if ( $e->value == array(2) ) {\n            $temp = new Math_BigInteger();\n            $temp->value = $this->_square($this->value);\n            list(, $temp) = $temp->divide($n);\n            return $this->_normalize($temp);\n        }\n\n        return $this->_normalize($this->_slidingWindow($e, $n, MATH_BIGINTEGER_BARRETT));\n\n        // is the modulo odd?\n        if ( $n->value[0] & 1 ) {\n            return $this->_normalize($this->_slidingWindow($e, $n, MATH_BIGINTEGER_MONTGOMERY));\n        }\n        // if it's not, it's even\n\n        // find the lowest set bit (eg. the max pow of 2 that divides $n)\n        for ($i = 0; $i < count($n->value); ++$i) {\n            if ( $n->value[$i] ) {\n                $temp = decbin($n->value[$i]);\n                $j = strlen($temp) - strrpos($temp, '1') - 1;\n                $j+= 26 * $i;\n                break;\n            }\n        }\n        // at this point, 2^$j * $n/(2^$j) == $n\n\n        $mod1 = $n->copy();\n        $mod1->_rshift($j);\n        $mod2 = new Math_BigInteger();\n        $mod2->value = array(1);\n        $mod2->_lshift($j);\n\n        $part1 = ( $mod1->value != array(1) ) ? $this->_slidingWindow($e, $mod1, MATH_BIGINTEGER_MONTGOMERY) : new Math_BigInteger();\n        $part2 = $this->_slidingWindow($e, $mod2, MATH_BIGINTEGER_POWEROF2);\n\n        $y1 = $mod2->modInverse($mod1);\n        $y2 = $mod1->modInverse($mod2);\n\n        $result = $part1->multiply($mod2);\n        $result = $result->multiply($y1);\n\n        $temp = $part2->multiply($mod1);\n        $temp = $temp->multiply($y2);\n\n        $result = $result->add($temp);\n        list(, $result) = $result->divide($n);\n\n        return $this->_normalize($result);\n    }\n\n    /**\n     * Performs modular exponentiation.\n     *\n     * Alias for Math_BigInteger::modPow()\n     *\n     * @param Math_BigInteger $e\n     * @param Math_BigInteger $n\n     * @return Math_BigInteger\n     * @access public\n     */\n    function powMod($e, $n)\n    {\n        return $this->modPow($e, $n);\n    }\n\n    /**\n     * Sliding Window k-ary Modular Exponentiation\n     *\n     * Based on {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=27 HAC 14.85} /\n     * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=210 MPM 7.7}.  In a departure from those algorithims,\n     * however, this function performs a modular reduction after every multiplication and squaring operation.\n     * As such, this function has the same preconditions that the reductions being used do.\n     *\n     * @param Math_BigInteger $e\n     * @param Math_BigInteger $n\n     * @param Integer $mode\n     * @return Math_BigInteger\n     * @access private\n     */\n    function _slidingWindow($e, $n, $mode)\n    {\n        static $window_ranges = array(7, 25, 81, 241, 673, 1793); // from BigInteger.java's oddModPow function\n        //static $window_ranges = array(0, 7, 36, 140, 450, 1303, 3529); // from MPM 7.3.1\n\n        $e_value = $e->value;\n        $e_length = count($e_value) - 1;\n        $e_bits = decbin($e_value[$e_length]);\n        for ($i = $e_length - 1; $i >= 0; --$i) {\n            $e_bits.= str_pad(decbin($e_value[$i]), MATH_BIGINTEGER_BASE, '0', STR_PAD_LEFT);\n        }\n\n        $e_length = strlen($e_bits);\n\n        // calculate the appropriate window size.\n        // $window_size == 3 if $window_ranges is between 25 and 81, for example.\n        for ($i = 0, $window_size = 1; $e_length > $window_ranges[$i] && $i < count($window_ranges); ++$window_size, ++$i);\n\n        $n_value = $n->value;\n\n        // precompute $this^0 through $this^$window_size\n        $powers = array();\n        $powers[1] = $this->_prepareReduce($this->value, $n_value, $mode);\n        $powers[2] = $this->_squareReduce($powers[1], $n_value, $mode);\n\n        // we do every other number since substr($e_bits, $i, $j+1) (see below) is supposed to end\n        // in a 1.  ie. it's supposed to be odd.\n        $temp = 1 << ($window_size - 1);\n        for ($i = 1; $i < $temp; ++$i) {\n            $i2 = $i << 1;\n            $powers[$i2 + 1] = $this->_multiplyReduce($powers[$i2 - 1], $powers[2], $n_value, $mode);\n        }\n\n        $result = array(1);\n        $result = $this->_prepareReduce($result, $n_value, $mode);\n\n        for ($i = 0; $i < $e_length; ) {\n            if ( !$e_bits[$i] ) {\n                $result = $this->_squareReduce($result, $n_value, $mode);\n                ++$i;\n            } else {\n                for ($j = $window_size - 1; $j > 0; --$j) {\n                    if ( !empty($e_bits[$i + $j]) ) {\n                        break;\n                    }\n                }\n\n                for ($k = 0; $k <= $j; ++$k) {// eg. the length of substr($e_bits, $i, $j+1)\n                    $result = $this->_squareReduce($result, $n_value, $mode);\n                }\n\n                $result = $this->_multiplyReduce($result, $powers[bindec(substr($e_bits, $i, $j + 1))], $n_value, $mode);\n\n                $i+=$j + 1;\n            }\n        }\n\n        $temp = new Math_BigInteger();\n        $temp->value = $this->_reduce($result, $n_value, $mode);\n\n        return $temp;\n    }\n\n    /**\n     * Modular reduction\n     *\n     * For most $modes this will return the remainder.\n     *\n     * @see _slidingWindow()\n     * @access private\n     * @param Array $x\n     * @param Array $n\n     * @param Integer $mode\n     * @return Array\n     */\n    function _reduce($x, $n, $mode)\n    {\n        switch ($mode) {\n            case MATH_BIGINTEGER_MONTGOMERY:\n                return $this->_montgomery($x, $n);\n            case MATH_BIGINTEGER_BARRETT:\n                return $this->_barrett($x, $n);\n            case MATH_BIGINTEGER_POWEROF2:\n                $lhs = new Math_BigInteger();\n                $lhs->value = $x;\n                $rhs = new Math_BigInteger();\n                $rhs->value = $n;\n                return $x->_mod2($n);\n            case MATH_BIGINTEGER_CLASSIC:\n                $lhs = new Math_BigInteger();\n                $lhs->value = $x;\n                $rhs = new Math_BigInteger();\n                $rhs->value = $n;\n                list(, $temp) = $lhs->divide($rhs);\n                return $temp->value;\n            case MATH_BIGINTEGER_NONE:\n                return $x;\n            default:\n                // an invalid $mode was provided\n        }\n    }\n\n    /**\n     * Modular reduction preperation\n     *\n     * @see _slidingWindow()\n     * @access private\n     * @param Array $x\n     * @param Array $n\n     * @param Integer $mode\n     * @return Array\n     */\n    function _prepareReduce($x, $n, $mode)\n    {\n        if ($mode == MATH_BIGINTEGER_MONTGOMERY) {\n            return $this->_prepMontgomery($x, $n);\n        }\n        return $this->_reduce($x, $n, $mode);\n    }\n\n    /**\n     * Modular multiply\n     *\n     * @see _slidingWindow()\n     * @access private\n     * @param Array $x\n     * @param Array $y\n     * @param Array $n\n     * @param Integer $mode\n     * @return Array\n     */\n    function _multiplyReduce($x, $y, $n, $mode)\n    {\n        if ($mode == MATH_BIGINTEGER_MONTGOMERY) {\n            return $this->_montgomeryMultiply($x, $y, $n);\n        }\n        $temp = $this->_multiply($x, false, $y, false);\n        return $this->_reduce($temp[MATH_BIGINTEGER_VALUE], $n, $mode);\n    }\n\n    /**\n     * Modular square\n     *\n     * @see _slidingWindow()\n     * @access private\n     * @param Array $x\n     * @param Array $n\n     * @param Integer $mode\n     * @return Array\n     */\n    function _squareReduce($x, $n, $mode)\n    {\n        if ($mode == MATH_BIGINTEGER_MONTGOMERY) {\n            return $this->_montgomeryMultiply($x, $x, $n);\n        }\n        return $this->_reduce($this->_square($x), $n, $mode);\n    }\n\n    /**\n     * Modulos for Powers of Two\n     *\n     * Calculates $x%$n, where $n = 2**$e, for some $e.  Since this is basically the same as doing $x & ($n-1),\n     * we'll just use this function as a wrapper for doing that.\n     *\n     * @see _slidingWindow()\n     * @access private\n     * @param Math_BigInteger\n     * @return Math_BigInteger\n     */\n    function _mod2($n)\n    {\n        $temp = new Math_BigInteger();\n        $temp->value = array(1);\n        return $this->bitwise_and($n->subtract($temp));\n    }\n\n    /**\n     * Barrett Modular Reduction\n     *\n     * See {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=14 HAC 14.3.3} /\n     * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=165 MPM 6.2.5} for more information.  Modified slightly,\n     * so as not to require negative numbers (initially, this script didn't support negative numbers).\n     *\n     * Employs \"folding\", as described at\n     * {@link http://www.cosic.esat.kuleuven.be/publications/thesis-149.pdf#page=66 thesis-149.pdf#page=66}.  To quote from\n     * it, \"the idea [behind folding] is to find a value x' such that x (mod m) = x' (mod m), with x' being smaller than x.\"\n     *\n     * Unfortunately, the \"Barrett Reduction with Folding\" algorithm described in thesis-149.pdf is not, as written, all that\n     * usable on account of (1) its not using reasonable radix points as discussed in\n     * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=162 MPM 6.2.2} and (2) the fact that, even with reasonable\n     * radix points, it only works when there are an even number of digits in the denominator.  The reason for (2) is that\n     * (x >> 1) + (x >> 1) != x / 2 + x / 2.  If x is even, they're the same, but if x is odd, they're not.  See the in-line\n     * comments for details.\n     *\n     * @see _slidingWindow()\n     * @access private\n     * @param Array $n\n     * @param Array $m\n     * @return Array\n     */\n    function _barrett($n, $m)\n    {\n        static $cache = array(\n            MATH_BIGINTEGER_VARIABLE => array(),\n            MATH_BIGINTEGER_DATA => array()\n        );\n\n        $m_length = count($m);\n\n        // if ($this->_compare($n, $this->_square($m)) >= 0) {\n        if (count($n) > 2 * $m_length) {\n            $lhs = new Math_BigInteger();\n            $rhs = new Math_BigInteger();\n            $lhs->value = $n;\n            $rhs->value = $m;\n            list(, $temp) = $lhs->divide($rhs);\n            return $temp->value;\n        }\n\n        // if (m.length >> 1) + 2 <= m.length then m is too small and n can't be reduced\n        if ($m_length < 5) {\n            return $this->_regularBarrett($n, $m);\n        }\n\n        // n = 2 * m.length\n\n        if ( ($key = array_search($m, $cache[MATH_BIGINTEGER_VARIABLE])) === false ) {\n            $key = count($cache[MATH_BIGINTEGER_VARIABLE]);\n            $cache[MATH_BIGINTEGER_VARIABLE][] = $m;\n\n            $lhs = new Math_BigInteger();\n            $lhs_value = &$lhs->value;\n            $lhs_value = $this->_array_repeat(0, $m_length + ($m_length >> 1));\n            $lhs_value[] = 1;\n            $rhs = new Math_BigInteger();\n            $rhs->value = $m;\n\n            list($u, $m1) = $lhs->divide($rhs);\n            $u = $u->value;\n            $m1 = $m1->value;\n\n            $cache[MATH_BIGINTEGER_DATA][] = array(\n                'u' => $u, // m.length >> 1 (technically (m.length >> 1) + 1)\n                'm1'=> $m1 // m.length\n            );\n        } else {\n            extract($cache[MATH_BIGINTEGER_DATA][$key]);\n        }\n\n        $cutoff = $m_length + ($m_length >> 1);\n        $lsd = array_slice($n, 0, $cutoff); // m.length + (m.length >> 1)\n        $msd = array_slice($n, $cutoff);    // m.length >> 1\n        $lsd = $this->_trim($lsd);\n        $temp = $this->_multiply($msd, false, $m1, false);\n        $n = $this->_add($lsd, false, $temp[MATH_BIGINTEGER_VALUE], false); // m.length + (m.length >> 1) + 1\n\n        if ($m_length & 1) {\n            return $this->_regularBarrett($n[MATH_BIGINTEGER_VALUE], $m);\n        }\n\n        // (m.length + (m.length >> 1) + 1) - (m.length - 1) == (m.length >> 1) + 2\n        $temp = array_slice($n[MATH_BIGINTEGER_VALUE], $m_length - 1);\n        // if even: ((m.length >> 1) + 2) + (m.length >> 1) == m.length + 2\n        // if odd:  ((m.length >> 1) + 2) + (m.length >> 1) == (m.length - 1) + 2 == m.length + 1\n        $temp = $this->_multiply($temp, false, $u, false);\n        // if even: (m.length + 2) - ((m.length >> 1) + 1) = m.length - (m.length >> 1) + 1\n        // if odd:  (m.length + 1) - ((m.length >> 1) + 1) = m.length - (m.length >> 1)\n        $temp = array_slice($temp[MATH_BIGINTEGER_VALUE], ($m_length >> 1) + 1);\n        // if even: (m.length - (m.length >> 1) + 1) + m.length = 2 * m.length - (m.length >> 1) + 1\n        // if odd:  (m.length - (m.length >> 1)) + m.length     = 2 * m.length - (m.length >> 1)\n        $temp = $this->_multiply($temp, false, $m, false);\n\n        // at this point, if m had an odd number of digits, we'd be subtracting a 2 * m.length - (m.length >> 1) digit\n        // number from a m.length + (m.length >> 1) + 1 digit number.  ie. there'd be an extra digit and the while loop\n        // following this comment would loop a lot (hence our calling _regularBarrett() in that situation).\n\n        $result = $this->_subtract($n[MATH_BIGINTEGER_VALUE], false, $temp[MATH_BIGINTEGER_VALUE], false);\n\n        while ($this->_compare($result[MATH_BIGINTEGER_VALUE], $result[MATH_BIGINTEGER_SIGN], $m, false) >= 0) {\n            $result = $this->_subtract($result[MATH_BIGINTEGER_VALUE], $result[MATH_BIGINTEGER_SIGN], $m, false);\n        }\n\n        return $result[MATH_BIGINTEGER_VALUE];\n    }\n\n    /**\n     * (Regular) Barrett Modular Reduction\n     *\n     * For numbers with more than four digits Math_BigInteger::_barrett() is faster.  The difference between that and this\n     * is that this function does not fold the denominator into a smaller form.\n     *\n     * @see _slidingWindow()\n     * @access private\n     * @param Array $x\n     * @param Array $n\n     * @return Array\n     */\n    function _regularBarrett($x, $n)\n    {\n        static $cache = array(\n            MATH_BIGINTEGER_VARIABLE => array(),\n            MATH_BIGINTEGER_DATA => array()\n        );\n\n        $n_length = count($n);\n\n        if (count($x) > 2 * $n_length) {\n            $lhs = new Math_BigInteger();\n            $rhs = new Math_BigInteger();\n            $lhs->value = $x;\n            $rhs->value = $n;\n            list(, $temp) = $lhs->divide($rhs);\n            return $temp->value;\n        }\n\n        if ( ($key = array_search($n, $cache[MATH_BIGINTEGER_VARIABLE])) === false ) {\n            $key = count($cache[MATH_BIGINTEGER_VARIABLE]);\n            $cache[MATH_BIGINTEGER_VARIABLE][] = $n;\n            $lhs = new Math_BigInteger();\n            $lhs_value = &$lhs->value;\n            $lhs_value = $this->_array_repeat(0, 2 * $n_length);\n            $lhs_value[] = 1;\n            $rhs = new Math_BigInteger();\n            $rhs->value = $n;\n            list($temp, ) = $lhs->divide($rhs); // m.length\n            $cache[MATH_BIGINTEGER_DATA][] = $temp->value;\n        }\n\n        // 2 * m.length - (m.length - 1) = m.length + 1\n        $temp = array_slice($x, $n_length - 1);\n        // (m.length + 1) + m.length = 2 * m.length + 1\n        $temp = $this->_multiply($temp, false, $cache[MATH_BIGINTEGER_DATA][$key], false);\n        // (2 * m.length + 1) - (m.length - 1) = m.length + 2\n        $temp = array_slice($temp[MATH_BIGINTEGER_VALUE], $n_length + 1);\n\n        // m.length + 1\n        $result = array_slice($x, 0, $n_length + 1);\n        // m.length + 1\n        $temp = $this->_multiplyLower($temp, false, $n, false, $n_length + 1);\n        // $temp == array_slice($temp->_multiply($temp, false, $n, false)->value, 0, $n_length + 1)\n\n        if ($this->_compare($result, false, $temp[MATH_BIGINTEGER_VALUE], $temp[MATH_BIGINTEGER_SIGN]) < 0) {\n            $corrector_value = $this->_array_repeat(0, $n_length + 1);\n            $corrector_value[] = 1;\n            $result = $this->_add($result, false, $corrector_value, false);\n            $result = $result[MATH_BIGINTEGER_VALUE];\n        }\n\n        // at this point, we're subtracting a number with m.length + 1 digits from another number with m.length + 1 digits\n        $result = $this->_subtract($result, false, $temp[MATH_BIGINTEGER_VALUE], $temp[MATH_BIGINTEGER_SIGN]);\n        while ($this->_compare($result[MATH_BIGINTEGER_VALUE], $result[MATH_BIGINTEGER_SIGN], $n, false) > 0) {\n            $result = $this->_subtract($result[MATH_BIGINTEGER_VALUE], $result[MATH_BIGINTEGER_SIGN], $n, false);\n        }\n\n        return $result[MATH_BIGINTEGER_VALUE];\n    }\n\n    /**\n     * Performs long multiplication up to $stop digits\n     *\n     * If you're going to be doing array_slice($product->value, 0, $stop), some cycles can be saved.\n     *\n     * @see _regularBarrett()\n     * @param Array $x_value\n     * @param Boolean $x_negative\n     * @param Array $y_value\n     * @param Boolean $y_negative\n     * @param Integer $stop\n     * @return Array\n     * @access private\n     */\n    function _multiplyLower($x_value, $x_negative, $y_value, $y_negative, $stop)\n    {\n        $x_length = count($x_value);\n        $y_length = count($y_value);\n\n        if ( !$x_length || !$y_length ) { // a 0 is being multiplied\n            return array(\n                MATH_BIGINTEGER_VALUE => array(),\n                MATH_BIGINTEGER_SIGN => false\n            );\n        }\n\n        if ( $x_length < $y_length ) {\n            $temp = $x_value;\n            $x_value = $y_value;\n            $y_value = $temp;\n\n            $x_length = count($x_value);\n            $y_length = count($y_value);\n        }\n\n        $product_value = $this->_array_repeat(0, $x_length + $y_length);\n\n        // the following for loop could be removed if the for loop following it\n        // (the one with nested for loops) initially set $i to 0, but\n        // doing so would also make the result in one set of unnecessary adds,\n        // since on the outermost loops first pass, $product->value[$k] is going\n        // to always be 0\n\n        $carry = 0;\n\n        for ($j = 0; $j < $x_length; ++$j) { // ie. $i = 0, $k = $i\n            $temp = $x_value[$j] * $y_value[0] + $carry; // $product_value[$k] == 0\n            $carry = (int) ($temp / MATH_BIGINTEGER_BASE_FULL);\n            $product_value[$j] = (int) ($temp - MATH_BIGINTEGER_BASE_FULL * $carry);\n        }\n\n        if ($j < $stop) {\n            $product_value[$j] = $carry;\n        }\n\n        // the above for loop is what the previous comment was talking about.  the\n        // following for loop is the \"one with nested for loops\"\n\n        for ($i = 1; $i < $y_length; ++$i) {\n            $carry = 0;\n\n            for ($j = 0, $k = $i; $j < $x_length && $k < $stop; ++$j, ++$k) {\n                $temp = $product_value[$k] + $x_value[$j] * $y_value[$i] + $carry;\n                $carry = (int) ($temp / MATH_BIGINTEGER_BASE_FULL);\n                $product_value[$k] = (int) ($temp - MATH_BIGINTEGER_BASE_FULL * $carry);\n            }\n\n            if ($k < $stop) {\n                $product_value[$k] = $carry;\n            }\n        }\n\n        return array(\n            MATH_BIGINTEGER_VALUE => $this->_trim($product_value),\n            MATH_BIGINTEGER_SIGN => $x_negative != $y_negative\n        );\n    }\n\n    /**\n     * Montgomery Modular Reduction\n     *\n     * ($x->_prepMontgomery($n))->_montgomery($n) yields $x % $n.\n     * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=170 MPM 6.3} provides insights on how this can be\n     * improved upon (basically, by using the comba method).  gcd($n, 2) must be equal to one for this function\n     * to work correctly.\n     *\n     * @see _prepMontgomery()\n     * @see _slidingWindow()\n     * @access private\n     * @param Array $x\n     * @param Array $n\n     * @return Array\n     */\n    function _montgomery($x, $n)\n    {\n        static $cache = array(\n            MATH_BIGINTEGER_VARIABLE => array(),\n            MATH_BIGINTEGER_DATA => array()\n        );\n\n        if ( ($key = array_search($n, $cache[MATH_BIGINTEGER_VARIABLE])) === false ) {\n            $key = count($cache[MATH_BIGINTEGER_VARIABLE]);\n            $cache[MATH_BIGINTEGER_VARIABLE][] = $x;\n            $cache[MATH_BIGINTEGER_DATA][] = $this->_modInverse67108864($n);\n        }\n\n        $k = count($n);\n\n        $result = array(MATH_BIGINTEGER_VALUE => $x);\n\n        for ($i = 0; $i < $k; ++$i) {\n            $temp = $result[MATH_BIGINTEGER_VALUE][$i] * $cache[MATH_BIGINTEGER_DATA][$key];\n            $temp = (int) ($temp - MATH_BIGINTEGER_BASE_FULL * ((int) ($temp / MATH_BIGINTEGER_BASE_FULL)));\n            $temp = $this->_regularMultiply(array($temp), $n);\n            $temp = array_merge($this->_array_repeat(0, $i), $temp);\n            $result = $this->_add($result[MATH_BIGINTEGER_VALUE], false, $temp, false);\n        }\n\n        $result[MATH_BIGINTEGER_VALUE] = array_slice($result[MATH_BIGINTEGER_VALUE], $k);\n\n        if ($this->_compare($result, false, $n, false) >= 0) {\n            $result = $this->_subtract($result[MATH_BIGINTEGER_VALUE], false, $n, false);\n        }\n\n        return $result[MATH_BIGINTEGER_VALUE];\n    }\n\n    /**\n     * Montgomery Multiply\n     *\n     * Interleaves the montgomery reduction and long multiplication algorithms together as described in\n     * {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=13 HAC 14.36}\n     *\n     * @see _prepMontgomery()\n     * @see _montgomery()\n     * @access private\n     * @param Array $x\n     * @param Array $y\n     * @param Array $m\n     * @return Array\n     */\n    function _montgomeryMultiply($x, $y, $m)\n    {\n        $temp = $this->_multiply($x, false, $y, false);\n        return $this->_montgomery($temp[MATH_BIGINTEGER_VALUE], $m);\n\n        static $cache = array(\n            MATH_BIGINTEGER_VARIABLE => array(),\n            MATH_BIGINTEGER_DATA => array()\n        );\n\n        if ( ($key = array_search($m, $cache[MATH_BIGINTEGER_VARIABLE])) === false ) {\n            $key = count($cache[MATH_BIGINTEGER_VARIABLE]);\n            $cache[MATH_BIGINTEGER_VARIABLE][] = $m;\n            $cache[MATH_BIGINTEGER_DATA][] = $this->_modInverse67108864($m);\n        }\n\n        $n = max(count($x), count($y), count($m));\n        $x = array_pad($x, $n, 0);\n        $y = array_pad($y, $n, 0);\n        $m = array_pad($m, $n, 0);\n        $a = array(MATH_BIGINTEGER_VALUE => $this->_array_repeat(0, $n + 1));\n        for ($i = 0; $i < $n; ++$i) {\n            $temp = $a[MATH_BIGINTEGER_VALUE][0] + $x[$i] * $y[0];\n            $temp = (int) ($temp - MATH_BIGINTEGER_BASE_FULL * ((int) ($temp / MATH_BIGINTEGER_BASE_FULL)));\n            $temp = $temp * $cache[MATH_BIGINTEGER_DATA][$key];\n            $temp = (int) ($temp - MATH_BIGINTEGER_BASE_FULL * ((int) ($temp / MATH_BIGINTEGER_BASE_FULL)));\n            $temp = $this->_add($this->_regularMultiply(array($x[$i]), $y), false, $this->_regularMultiply(array($temp), $m), false);\n            $a = $this->_add($a[MATH_BIGINTEGER_VALUE], false, $temp[MATH_BIGINTEGER_VALUE], false);\n            $a[MATH_BIGINTEGER_VALUE] = array_slice($a[MATH_BIGINTEGER_VALUE], 1);\n        }\n        if ($this->_compare($a[MATH_BIGINTEGER_VALUE], false, $m, false) >= 0) {\n            $a = $this->_subtract($a[MATH_BIGINTEGER_VALUE], false, $m, false);\n        }\n        return $a[MATH_BIGINTEGER_VALUE];\n    }\n\n    /**\n     * Prepare a number for use in Montgomery Modular Reductions\n     *\n     * @see _montgomery()\n     * @see _slidingWindow()\n     * @access private\n     * @param Array $x\n     * @param Array $n\n     * @return Array\n     */\n    function _prepMontgomery($x, $n)\n    {\n        $lhs = new Math_BigInteger();\n        $lhs->value = array_merge($this->_array_repeat(0, count($n)), $x);\n        $rhs = new Math_BigInteger();\n        $rhs->value = $n;\n\n        list(, $temp) = $lhs->divide($rhs);\n        return $temp->value;\n    }\n\n    /**\n     * Modular Inverse of a number mod 2**26 (eg. 67108864)\n     *\n     * Based off of the bnpInvDigit function implemented and justified in the following URL:\n     *\n     * {@link http://www-cs-students.stanford.edu/~tjw/jsbn/jsbn.js}\n     *\n     * The following URL provides more info:\n     *\n     * {@link http://groups.google.com/group/sci.crypt/msg/7a137205c1be7d85}\n     *\n     * As for why we do all the bitmasking...  strange things can happen when converting from floats to ints. For\n     * instance, on some computers, var_dump((int) -4294967297) yields int(-1) and on others, it yields\n     * int(-2147483648).  To avoid problems stemming from this, we use bitmasks to guarantee that ints aren't\n     * auto-converted to floats.  The outermost bitmask is present because without it, there's no guarantee that\n     * the \"residue\" returned would be the so-called \"common residue\".  We use fmod, in the last step, because the\n     * maximum possible $x is 26 bits and the maximum $result is 16 bits.  Thus, we have to be able to handle up to\n     * 40 bits, which only 64-bit floating points will support.\n     *\n     * Thanks to Pedro Gimeno Fortea for input!\n     *\n     * @see _montgomery()\n     * @access private\n     * @param Array $x\n     * @return Integer\n     */\n    function _modInverse67108864($x) // 2**26 == 67,108,864\n    {\n        $x = -$x[0];\n        $result = $x & 0x3; // x**-1 mod 2**2\n        $result = ($result * (2 - $x * $result)) & 0xF; // x**-1 mod 2**4\n        $result = ($result * (2 - ($x & 0xFF) * $result))  & 0xFF; // x**-1 mod 2**8\n        $result = ($result * ((2 - ($x & 0xFFFF) * $result) & 0xFFFF)) & 0xFFFF; // x**-1 mod 2**16\n        $result = fmod($result * (2 - fmod($x * $result, MATH_BIGINTEGER_BASE_FULL)), MATH_BIGINTEGER_BASE_FULL); // x**-1 mod 2**26\n        return $result & MATH_BIGINTEGER_MAX_DIGIT;\n    }\n\n    /**\n     * Calculates modular inverses.\n     *\n     * Say you have (30 mod 17 * x mod 17) mod 17 == 1.  x can be found using modular inverses.\n     *\n     * Here's an example:\n     * <code>\n     * <?php\n     *    include('Math/BigInteger.php');\n     *\n     *    $a = new Math_BigInteger(30);\n     *    $b = new Math_BigInteger(17);\n     *\n     *    $c = $a->modInverse($b);\n     *    echo $c->toString(); // outputs 4\n     *\n     *    echo \"\\r\\n\";\n     *\n     *    $d = $a->multiply($c);\n     *    list(, $d) = $d->divide($b);\n     *    echo $d; // outputs 1 (as per the definition of modular inverse)\n     * ?>\n     * </code>\n     *\n     * @param Math_BigInteger $n\n     * @return mixed false, if no modular inverse exists, Math_BigInteger, otherwise.\n     * @access public\n     * @internal See {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=21 HAC 14.64} for more information.\n     */\n    function modInverse($n)\n    {\n        switch ( MATH_BIGINTEGER_MODE ) {\n            case MATH_BIGINTEGER_MODE_GMP:\n                $temp = new Math_BigInteger();\n                $temp->value = gmp_invert($this->value, $n->value);\n\n                return ( $temp->value === false ) ? false : $this->_normalize($temp);\n        }\n\n        static $zero, $one;\n        if (!isset($zero)) {\n            $zero = new Math_BigInteger();\n            $one = new Math_BigInteger(1);\n        }\n\n        // $x mod -$n == $x mod $n.\n        $n = $n->abs();\n\n        if ($this->compare($zero) < 0) {\n            $temp = $this->abs();\n            $temp = $temp->modInverse($n);\n            return $this->_normalize($n->subtract($temp));\n        }\n\n        extract($this->extendedGCD($n));\n\n        if (!$gcd->equals($one)) {\n            return false;\n        }\n\n        $x = $x->compare($zero) < 0 ? $x->add($n) : $x;\n\n        return $this->compare($zero) < 0 ? $this->_normalize($n->subtract($x)) : $this->_normalize($x);\n    }\n\n    /**\n     * Calculates the greatest common divisor and Bezout's identity.\n     *\n     * Say you have 693 and 609.  The GCD is 21.  Bezout's identity states that there exist integers x and y such that\n     * 693*x + 609*y == 21.  In point of fact, there are actually an infinite number of x and y combinations and which\n     * combination is returned is dependant upon which mode is in use.  See\n     * {@link http://en.wikipedia.org/wiki/B%C3%A9zout%27s_identity Bezout's identity - Wikipedia} for more information.\n     *\n     * Here's an example:\n     * <code>\n     * <?php\n     *    include('Math/BigInteger.php');\n     *\n     *    $a = new Math_BigInteger(693);\n     *    $b = new Math_BigInteger(609);\n     *\n     *    extract($a->extendedGCD($b));\n     *\n     *    echo $gcd->toString() . \"\\r\\n\"; // outputs 21\n     *    echo $a->toString() * $x->toString() + $b->toString() * $y->toString(); // outputs 21\n     * ?>\n     * </code>\n     *\n     * @param Math_BigInteger $n\n     * @return Math_BigInteger\n     * @access public\n     * @internal Calculates the GCD using the binary xGCD algorithim described in\n     *    {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=19 HAC 14.61}.  As the text above 14.61 notes,\n     *    the more traditional algorithim requires \"relatively costly multiple-precision divisions\".\n     */\n    function extendedGCD($n)\n    {\n        switch ( MATH_BIGINTEGER_MODE ) {\n            case MATH_BIGINTEGER_MODE_GMP:\n                extract(gmp_gcdext($this->value, $n->value));\n\n                return array(\n                    'gcd' => $this->_normalize(new Math_BigInteger($g)),\n                    'x'   => $this->_normalize(new Math_BigInteger($s)),\n                    'y'   => $this->_normalize(new Math_BigInteger($t))\n                );\n            case MATH_BIGINTEGER_MODE_BCMATH:\n                // it might be faster to use the binary xGCD algorithim here, as well, but (1) that algorithim works\n                // best when the base is a power of 2 and (2) i don't think it'd make much difference, anyway.  as is,\n                // the basic extended euclidean algorithim is what we're using.\n\n                $u = $this->value;\n                $v = $n->value;\n\n                $a = '1';\n                $b = '0';\n                $c = '0';\n                $d = '1';\n\n                while (bccomp($v, '0', 0) != 0) {\n                    $q = bcdiv($u, $v, 0);\n\n                    $temp = $u;\n                    $u = $v;\n                    $v = bcsub($temp, bcmul($v, $q, 0), 0);\n\n                    $temp = $a;\n                    $a = $c;\n                    $c = bcsub($temp, bcmul($a, $q, 0), 0);\n\n                    $temp = $b;\n                    $b = $d;\n                    $d = bcsub($temp, bcmul($b, $q, 0), 0);\n                }\n\n                return array(\n                    'gcd' => $this->_normalize(new Math_BigInteger($u)),\n                    'x'   => $this->_normalize(new Math_BigInteger($a)),\n                    'y'   => $this->_normalize(new Math_BigInteger($b))\n                );\n        }\n\n        $y = $n->copy();\n        $x = $this->copy();\n        $g = new Math_BigInteger();\n        $g->value = array(1);\n\n        while ( !(($x->value[0] & 1)|| ($y->value[0] & 1)) ) {\n            $x->_rshift(1);\n            $y->_rshift(1);\n            $g->_lshift(1);\n        }\n\n        $u = $x->copy();\n        $v = $y->copy();\n\n        $a = new Math_BigInteger();\n        $b = new Math_BigInteger();\n        $c = new Math_BigInteger();\n        $d = new Math_BigInteger();\n\n        $a->value = $d->value = $g->value = array(1);\n        $b->value = $c->value = array();\n\n        while ( !empty($u->value) ) {\n            while ( !($u->value[0] & 1) ) {\n                $u->_rshift(1);\n                if ( (!empty($a->value) && ($a->value[0] & 1)) || (!empty($b->value) && ($b->value[0] & 1)) ) {\n                    $a = $a->add($y);\n                    $b = $b->subtract($x);\n                }\n                $a->_rshift(1);\n                $b->_rshift(1);\n            }\n\n            while ( !($v->value[0] & 1) ) {\n                $v->_rshift(1);\n                if ( (!empty($d->value) && ($d->value[0] & 1)) || (!empty($c->value) && ($c->value[0] & 1)) ) {\n                    $c = $c->add($y);\n                    $d = $d->subtract($x);\n                }\n                $c->_rshift(1);\n                $d->_rshift(1);\n            }\n\n            if ($u->compare($v) >= 0) {\n                $u = $u->subtract($v);\n                $a = $a->subtract($c);\n                $b = $b->subtract($d);\n            } else {\n                $v = $v->subtract($u);\n                $c = $c->subtract($a);\n                $d = $d->subtract($b);\n            }\n        }\n\n        return array(\n            'gcd' => $this->_normalize($g->multiply($v)),\n            'x'   => $this->_normalize($c),\n            'y'   => $this->_normalize($d)\n        );\n    }\n\n    /**\n     * Calculates the greatest common divisor\n     *\n     * Say you have 693 and 609.  The GCD is 21.\n     *\n     * Here's an example:\n     * <code>\n     * <?php\n     *    include('Math/BigInteger.php');\n     *\n     *    $a = new Math_BigInteger(693);\n     *    $b = new Math_BigInteger(609);\n     *\n     *    $gcd = a->extendedGCD($b);\n     *\n     *    echo $gcd->toString() . \"\\r\\n\"; // outputs 21\n     * ?>\n     * </code>\n     *\n     * @param Math_BigInteger $n\n     * @return Math_BigInteger\n     * @access public\n     */\n    function gcd($n)\n    {\n        extract($this->extendedGCD($n));\n        return $gcd;\n    }\n\n    /**\n     * Absolute value.\n     *\n     * @return Math_BigInteger\n     * @access public\n     */\n    function abs()\n    {\n        $temp = new Math_BigInteger();\n\n        switch ( MATH_BIGINTEGER_MODE ) {\n            case MATH_BIGINTEGER_MODE_GMP:\n                $temp->value = gmp_abs($this->value);\n                break;\n            case MATH_BIGINTEGER_MODE_BCMATH:\n                $temp->value = (bccomp($this->value, '0', 0) < 0) ? substr($this->value, 1) : $this->value;\n                break;\n            default:\n                $temp->value = $this->value;\n        }\n\n        return $temp;\n    }\n\n    /**\n     * Compares two numbers.\n     *\n     * Although one might think !$x->compare($y) means $x != $y, it, in fact, means the opposite.  The reason for this is\n     * demonstrated thusly:\n     *\n     * $x  > $y: $x->compare($y)  > 0\n     * $x  < $y: $x->compare($y)  < 0\n     * $x == $y: $x->compare($y) == 0\n     *\n     * Note how the same comparison operator is used.  If you want to test for equality, use $x->equals($y).\n     *\n     * @param Math_BigInteger $y\n     * @return Integer < 0 if $this is less than $y; > 0 if $this is greater than $y, and 0 if they are equal.\n     * @access public\n     * @see equals()\n     * @internal Could return $this->subtract($x), but that's not as fast as what we do do.\n     */\n    function compare($y)\n    {\n        switch ( MATH_BIGINTEGER_MODE ) {\n            case MATH_BIGINTEGER_MODE_GMP:\n                return gmp_cmp($this->value, $y->value);\n            case MATH_BIGINTEGER_MODE_BCMATH:\n                return bccomp($this->value, $y->value, 0);\n        }\n\n        return $this->_compare($this->value, $this->is_negative, $y->value, $y->is_negative);\n    }\n\n    /**\n     * Compares two numbers.\n     *\n     * @param Array $x_value\n     * @param Boolean $x_negative\n     * @param Array $y_value\n     * @param Boolean $y_negative\n     * @return Integer\n     * @see compare()\n     * @access private\n     */\n    function _compare($x_value, $x_negative, $y_value, $y_negative)\n    {\n        if ( $x_negative != $y_negative ) {\n            return ( !$x_negative && $y_negative ) ? 1 : -1;\n        }\n\n        $result = $x_negative ? -1 : 1;\n\n        if ( count($x_value) != count($y_value) ) {\n            return ( count($x_value) > count($y_value) ) ? $result : -$result;\n        }\n        $size = max(count($x_value), count($y_value));\n\n        $x_value = array_pad($x_value, $size, 0);\n        $y_value = array_pad($y_value, $size, 0);\n\n        for ($i = count($x_value) - 1; $i >= 0; --$i) {\n            if ($x_value[$i] != $y_value[$i]) {\n                return ( $x_value[$i] > $y_value[$i] ) ? $result : -$result;\n            }\n        }\n\n        return 0;\n    }\n\n    /**\n     * Tests the equality of two numbers.\n     *\n     * If you need to see if one number is greater than or less than another number, use Math_BigInteger::compare()\n     *\n     * @param Math_BigInteger $x\n     * @return Boolean\n     * @access public\n     * @see compare()\n     */\n    function equals($x)\n    {\n        switch ( MATH_BIGINTEGER_MODE ) {\n            case MATH_BIGINTEGER_MODE_GMP:\n                return gmp_cmp($this->value, $x->value) == 0;\n            default:\n                return $this->value === $x->value && $this->is_negative == $x->is_negative;\n        }\n    }\n\n    /**\n     * Set Precision\n     *\n     * Some bitwise operations give different results depending on the precision being used.  Examples include left\n     * shift, not, and rotates.\n     *\n     * @param Integer $bits\n     * @access public\n     */\n    function setPrecision($bits)\n    {\n        $this->precision = $bits;\n        if ( MATH_BIGINTEGER_MODE != MATH_BIGINTEGER_MODE_BCMATH ) {\n            $this->bitmask = new Math_BigInteger(chr((1 << ($bits & 0x7)) - 1) . str_repeat(chr(0xFF), $bits >> 3), 256);\n        } else {\n            $this->bitmask = new Math_BigInteger(bcpow('2', $bits, 0));\n        }\n\n        $temp = $this->_normalize($this);\n        $this->value = $temp->value;\n    }\n\n    /**\n     * Logical And\n     *\n     * @param Math_BigInteger $x\n     * @access public\n     * @internal Implemented per a request by Lluis Pamies i Juarez <lluis _a_ pamies.cat>\n     * @return Math_BigInteger\n     */\n    function bitwise_and($x)\n    {\n        switch ( MATH_BIGINTEGER_MODE ) {\n            case MATH_BIGINTEGER_MODE_GMP:\n                $temp = new Math_BigInteger();\n                $temp->value = gmp_and($this->value, $x->value);\n\n                return $this->_normalize($temp);\n            case MATH_BIGINTEGER_MODE_BCMATH:\n                $left = $this->toBytes();\n                $right = $x->toBytes();\n\n                $length = max(strlen($left), strlen($right));\n\n                $left = str_pad($left, $length, chr(0), STR_PAD_LEFT);\n                $right = str_pad($right, $length, chr(0), STR_PAD_LEFT);\n\n                return $this->_normalize(new Math_BigInteger($left & $right, 256));\n        }\n\n        $result = $this->copy();\n\n        $length = min(count($x->value), count($this->value));\n\n        $result->value = array_slice($result->value, 0, $length);\n\n        for ($i = 0; $i < $length; ++$i) {\n            $result->value[$i]&= $x->value[$i];\n        }\n\n        return $this->_normalize($result);\n    }\n\n    /**\n     * Logical Or\n     *\n     * @param Math_BigInteger $x\n     * @access public\n     * @internal Implemented per a request by Lluis Pamies i Juarez <lluis _a_ pamies.cat>\n     * @return Math_BigInteger\n     */\n    function bitwise_or($x)\n    {\n        switch ( MATH_BIGINTEGER_MODE ) {\n            case MATH_BIGINTEGER_MODE_GMP:\n                $temp = new Math_BigInteger();\n                $temp->value = gmp_or($this->value, $x->value);\n\n                return $this->_normalize($temp);\n            case MATH_BIGINTEGER_MODE_BCMATH:\n                $left = $this->toBytes();\n                $right = $x->toBytes();\n\n                $length = max(strlen($left), strlen($right));\n\n                $left = str_pad($left, $length, chr(0), STR_PAD_LEFT);\n                $right = str_pad($right, $length, chr(0), STR_PAD_LEFT);\n\n                return $this->_normalize(new Math_BigInteger($left | $right, 256));\n        }\n\n        $length = max(count($this->value), count($x->value));\n        $result = $this->copy();\n        $result->value = array_pad($result->value, $length, 0);\n        $x->value = array_pad($x->value, $length, 0);\n\n        for ($i = 0; $i < $length; ++$i) {\n            $result->value[$i]|= $x->value[$i];\n        }\n\n        return $this->_normalize($result);\n    }\n\n    /**\n     * Logical Exclusive-Or\n     *\n     * @param Math_BigInteger $x\n     * @access public\n     * @internal Implemented per a request by Lluis Pamies i Juarez <lluis _a_ pamies.cat>\n     * @return Math_BigInteger\n     */\n    function bitwise_xor($x)\n    {\n        switch ( MATH_BIGINTEGER_MODE ) {\n            case MATH_BIGINTEGER_MODE_GMP:\n                $temp = new Math_BigInteger();\n                $temp->value = gmp_xor($this->value, $x->value);\n\n                return $this->_normalize($temp);\n            case MATH_BIGINTEGER_MODE_BCMATH:\n                $left = $this->toBytes();\n                $right = $x->toBytes();\n\n                $length = max(strlen($left), strlen($right));\n\n                $left = str_pad($left, $length, chr(0), STR_PAD_LEFT);\n                $right = str_pad($right, $length, chr(0), STR_PAD_LEFT);\n\n                return $this->_normalize(new Math_BigInteger($left ^ $right, 256));\n        }\n\n        $length = max(count($this->value), count($x->value));\n        $result = $this->copy();\n        $result->value = array_pad($result->value, $length, 0);\n        $x->value = array_pad($x->value, $length, 0);\n\n        for ($i = 0; $i < $length; ++$i) {\n            $result->value[$i]^= $x->value[$i];\n        }\n\n        return $this->_normalize($result);\n    }\n\n    /**\n     * Logical Not\n     *\n     * @access public\n     * @internal Implemented per a request by Lluis Pamies i Juarez <lluis _a_ pamies.cat>\n     * @return Math_BigInteger\n     */\n    function bitwise_not()\n    {\n        // calculuate \"not\" without regard to $this->precision\n        // (will always result in a smaller number.  ie. ~1 isn't 1111 1110 - it's 0)\n        $temp = $this->toBytes();\n        $pre_msb = decbin(ord($temp[0]));\n        $temp = ~$temp;\n        $msb = decbin(ord($temp[0]));\n        if (strlen($msb) == 8) {\n            $msb = substr($msb, strpos($msb, '0'));\n        }\n        $temp[0] = chr(bindec($msb));\n\n        // see if we need to add extra leading 1's\n        $current_bits = strlen($pre_msb) + 8 * strlen($temp) - 8;\n        $new_bits = $this->precision - $current_bits;\n        if ($new_bits <= 0) {\n            return $this->_normalize(new Math_BigInteger($temp, 256));\n        }\n\n        // generate as many leading 1's as we need to.\n        $leading_ones = chr((1 << ($new_bits & 0x7)) - 1) . str_repeat(chr(0xFF), $new_bits >> 3);\n        $this->_base256_lshift($leading_ones, $current_bits);\n\n        $temp = str_pad($temp, ceil($this->bits / 8), chr(0), STR_PAD_LEFT);\n\n        return $this->_normalize(new Math_BigInteger($leading_ones | $temp, 256));\n    }\n\n    /**\n     * Logical Right Shift\n     *\n     * Shifts BigInteger's by $shift bits, effectively dividing by 2**$shift.\n     *\n     * @param Integer $shift\n     * @return Math_BigInteger\n     * @access public\n     * @internal The only version that yields any speed increases is the internal version.\n     */\n    function bitwise_rightShift($shift)\n    {\n        $temp = new Math_BigInteger();\n\n        switch ( MATH_BIGINTEGER_MODE ) {\n            case MATH_BIGINTEGER_MODE_GMP:\n                static $two;\n\n                if (!isset($two)) {\n                    $two = gmp_init('2');\n                }\n\n                $temp->value = gmp_div_q($this->value, gmp_pow($two, $shift));\n\n                break;\n            case MATH_BIGINTEGER_MODE_BCMATH:\n                $temp->value = bcdiv($this->value, bcpow('2', $shift, 0), 0);\n\n                break;\n            default: // could just replace _lshift with this, but then all _lshift() calls would need to be rewritten\n                     // and I don't want to do that...\n                $temp->value = $this->value;\n                $temp->_rshift($shift);\n        }\n\n        return $this->_normalize($temp);\n    }\n\n    /**\n     * Logical Left Shift\n     *\n     * Shifts BigInteger's by $shift bits, effectively multiplying by 2**$shift.\n     *\n     * @param Integer $shift\n     * @return Math_BigInteger\n     * @access public\n     * @internal The only version that yields any speed increases is the internal version.\n     */\n    function bitwise_leftShift($shift)\n    {\n        $temp = new Math_BigInteger();\n\n        switch ( MATH_BIGINTEGER_MODE ) {\n            case MATH_BIGINTEGER_MODE_GMP:\n                static $two;\n\n                if (!isset($two)) {\n                    $two = gmp_init('2');\n                }\n\n                $temp->value = gmp_mul($this->value, gmp_pow($two, $shift));\n\n                break;\n            case MATH_BIGINTEGER_MODE_BCMATH:\n                $temp->value = bcmul($this->value, bcpow('2', $shift, 0), 0);\n\n                break;\n            default: // could just replace _rshift with this, but then all _lshift() calls would need to be rewritten\n                     // and I don't want to do that...\n                $temp->value = $this->value;\n                $temp->_lshift($shift);\n        }\n\n        return $this->_normalize($temp);\n    }\n\n    /**\n     * Logical Left Rotate\n     *\n     * Instead of the top x bits being dropped they're appended to the shifted bit string.\n     *\n     * @param Integer $shift\n     * @return Math_BigInteger\n     * @access public\n     */\n    function bitwise_leftRotate($shift)\n    {\n        $bits = $this->toBytes();\n\n        if ($this->precision > 0) {\n            $precision = $this->precision;\n            if ( MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_BCMATH ) {\n                $mask = $this->bitmask->subtract(new Math_BigInteger(1));\n                $mask = $mask->toBytes();\n            } else {\n                $mask = $this->bitmask->toBytes();\n            }\n        } else {\n            $temp = ord($bits[0]);\n            for ($i = 0; $temp >> $i; ++$i);\n            $precision = 8 * strlen($bits) - 8 + $i;\n            $mask = chr((1 << ($precision & 0x7)) - 1) . str_repeat(chr(0xFF), $precision >> 3);\n        }\n\n        if ($shift < 0) {\n            $shift+= $precision;\n        }\n        $shift%= $precision;\n\n        if (!$shift) {\n            return $this->copy();\n        }\n\n        $left = $this->bitwise_leftShift($shift);\n        $left = $left->bitwise_and(new Math_BigInteger($mask, 256));\n        $right = $this->bitwise_rightShift($precision - $shift);\n        $result = MATH_BIGINTEGER_MODE != MATH_BIGINTEGER_MODE_BCMATH ? $left->bitwise_or($right) : $left->add($right);\n        return $this->_normalize($result);\n    }\n\n    /**\n     * Logical Right Rotate\n     *\n     * Instead of the bottom x bits being dropped they're prepended to the shifted bit string.\n     *\n     * @param Integer $shift\n     * @return Math_BigInteger\n     * @access public\n     */\n    function bitwise_rightRotate($shift)\n    {\n        return $this->bitwise_leftRotate(-$shift);\n    }\n\n    /**\n     * Set random number generator function\n     *\n     * This function is deprecated.\n     *\n     * @param String $generator\n     * @access public\n     */\n    function setRandomGenerator($generator)\n    {\n    }\n\n    /**\n     * Generates a random BigInteger\n     *\n     * Byte length is equal to $length. Uses crypt_random if it's loaded and mt_rand if it's not.\n     *\n     * @param Integer $length\n     * @return Math_BigInteger\n     * @access private\n     */\n    function _random_number_helper($size)\n    {\n        $crypt_random = function_exists('crypt_random_string') || (!class_exists('Crypt_Random') && function_exists('crypt_random_string'));\n        if ($crypt_random) {\n            $random = crypt_random_string($size);\n        } else {\n            $random = '';\n\n            if ($size & 1) {\n                $random.= chr(mt_rand(0, 255));\n            }\n\n            $blocks = $size >> 1;\n            for ($i = 0; $i < $blocks; ++$i) {\n                // mt_rand(-2147483648, 0x7FFFFFFF) always produces -2147483648 on some systems\n                $random.= pack('n', mt_rand(0, 0xFFFF));\n            }\n        }\n\n        return new Math_BigInteger($random, 256);\n    }\n\n    /**\n     * Generate a random number\n     *\n     * @param optional Integer $min\n     * @param optional Integer $max\n     * @return Math_BigInteger\n     * @access public\n     */\n    function random($min = false, $max = false)\n    {\n        if ($min === false) {\n            $min = new Math_BigInteger(0);\n        }\n\n        if ($max === false) {\n            $max = new Math_BigInteger(0x7FFFFFFF);\n        }\n\n        $compare = $max->compare($min);\n\n        if (!$compare) {\n            return $this->_normalize($min);\n        } else if ($compare < 0) {\n            // if $min is bigger then $max, swap $min and $max\n            $temp = $max;\n            $max = $min;\n            $min = $temp;\n        }\n\n        static $one;\n        if (!isset($one)) {\n            $one = new Math_BigInteger(1);\n        }\n\n        $max = $max->subtract($min->subtract($one));\n        $size = strlen(ltrim($max->toBytes(), chr(0)));\n\n        /*\n            doing $random % $max doesn't work because some numbers will be more likely to occur than others.\n            eg. if $max is 140 and $random's max is 255 then that'd mean both $random = 5 and $random = 145\n            would produce 5 whereas the only value of random that could produce 139 would be 139. ie.\n            not all numbers would be equally likely. some would be more likely than others.\n\n            creating a whole new random number until you find one that is within the range doesn't work\n            because, for sufficiently small ranges, the likelihood that you'd get a number within that range\n            would be pretty small. eg. with $random's max being 255 and if your $max being 1 the probability\n            would be pretty high that $random would be greater than $max.\n\n            phpseclib works around this using the technique described here:\n\n            http://crypto.stackexchange.com/questions/5708/creating-a-small-number-from-a-cryptographically-secure-random-string\n        */\n        $random_max = new Math_BigInteger(chr(1) . str_repeat(\"\\0\", $size), 256);\n        $random = $this->_random_number_helper($size);\n\n        list($max_multiple) = $random_max->divide($max);\n        $max_multiple = $max_multiple->multiply($max);\n\n        while ($random->compare($max_multiple) >= 0) {\n            $random = $random->subtract($max_multiple);\n            $random_max = $random_max->subtract($max_multiple);\n            $random = $random->bitwise_leftShift(8);\n            $random = $random->add($this->_random_number_helper(1));\n            $random_max = $random_max->bitwise_leftShift(8);\n            list($max_multiple) = $random_max->divide($max);\n            $max_multiple = $max_multiple->multiply($max);\n        }\n        list(, $random) = $random->divide($max);\n\n        return $this->_normalize($random->add($min));\n    }\n\n    /**\n     * Generate a random prime number.\n     *\n     * If there's not a prime within the given range, false will be returned.  If more than $timeout seconds have elapsed,\n     * give up and return false.\n     *\n     * @param optional Integer $min\n     * @param optional Integer $max\n     * @param optional Integer $timeout\n     * @return Math_BigInteger\n     * @access public\n     * @internal See {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap4.pdf#page=15 HAC 4.44}.\n     */\n    function randomPrime($min = false, $max = false, $timeout = false)\n    {\n        if ($min === false) {\n            $min = new Math_BigInteger(0);\n        }\n\n        if ($max === false) {\n            $max = new Math_BigInteger(0x7FFFFFFF);\n        }\n\n        $compare = $max->compare($min);\n\n        if (!$compare) {\n            return $min->isPrime() ? $min : false;\n        } else if ($compare < 0) {\n            // if $min is bigger then $max, swap $min and $max\n            $temp = $max;\n            $max = $min;\n            $min = $temp;\n        }\n\n        static $one, $two;\n        if (!isset($one)) {\n            $one = new Math_BigInteger(1);\n            $two = new Math_BigInteger(2);\n        }\n\n        $start = time();\n\n        $x = $this->random($min, $max);\n\n        // gmp_nextprime() requires PHP 5 >= 5.2.0 per <http://php.net/gmp-nextprime>.\n        if ( MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_GMP && function_exists('gmp_nextprime') ) {\n            $p = new Math_BigInteger();\n            $p->value = gmp_nextprime($x->value);\n\n            if ($p->compare($max) <= 0) {\n                return $p;\n            }\n\n            if (!$min->equals($x)) {\n                $x = $x->subtract($one);\n            }\n\n            return $x->randomPrime($min, $x);\n        }\n\n        if ($x->equals($two)) {\n            return $x;\n        }\n\n        $x->_make_odd();\n        if ($x->compare($max) > 0) {\n            // if $x > $max then $max is even and if $min == $max then no prime number exists between the specified range\n            if ($min->equals($max)) {\n                return false;\n            }\n            $x = $min->copy();\n            $x->_make_odd();\n        }\n\n        $initial_x = $x->copy();\n\n        while (true) {\n            if ($timeout !== false && time() - $start > $timeout) {\n                return false;\n            }\n\n            if ($x->isPrime()) {\n                return $x;\n            }\n\n            $x = $x->add($two);\n\n            if ($x->compare($max) > 0) {\n                $x = $min->copy();\n                if ($x->equals($two)) {\n                    return $x;\n                }\n                $x->_make_odd();\n            }\n\n            if ($x->equals($initial_x)) {\n                return false;\n            }\n        }\n    }\n\n    /**\n     * Make the current number odd\n     *\n     * If the current number is odd it'll be unchanged.  If it's even, one will be added to it.\n     *\n     * @see randomPrime()\n     * @access private\n     */\n    function _make_odd()\n    {\n        switch ( MATH_BIGINTEGER_MODE ) {\n            case MATH_BIGINTEGER_MODE_GMP:\n                gmp_setbit($this->value, 0);\n                break;\n            case MATH_BIGINTEGER_MODE_BCMATH:\n                if ($this->value[strlen($this->value) - 1] % 2 == 0) {\n                    $this->value = bcadd($this->value, '1');\n                }\n                break;\n            default:\n                $this->value[0] |= 1;\n        }\n    }\n\n    /**\n     * Checks a numer to see if it's prime\n     *\n     * Assuming the $t parameter is not set, this function has an error rate of 2**-80.  The main motivation for the\n     * $t parameter is distributability.  Math_BigInteger::randomPrime() can be distributed accross multiple pageloads\n     * on a website instead of just one.\n     *\n     * @param optional Integer $t\n     * @return Boolean\n     * @access public\n     * @internal Uses the\n     *     {@link http://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test Miller-Rabin primality test}.  See\n     *     {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap4.pdf#page=8 HAC 4.24}.\n     */\n    function isPrime($t = false)\n    {\n        $length = strlen($this->toBytes());\n\n        if (!$t) {\n            // see HAC 4.49 \"Note (controlling the error probability)\"\n            // @codingStandardsIgnoreStart\n                 if ($length >= 163) { $t =  2; } // floor(1300 / 8)\n            else if ($length >= 106) { $t =  3; } // floor( 850 / 8)\n            else if ($length >= 81 ) { $t =  4; } // floor( 650 / 8)\n            else if ($length >= 68 ) { $t =  5; } // floor( 550 / 8)\n            else if ($length >= 56 ) { $t =  6; } // floor( 450 / 8)\n            else if ($length >= 50 ) { $t =  7; } // floor( 400 / 8)\n            else if ($length >= 43 ) { $t =  8; } // floor( 350 / 8)\n            else if ($length >= 37 ) { $t =  9; } // floor( 300 / 8)\n            else if ($length >= 31 ) { $t = 12; } // floor( 250 / 8)\n            else if ($length >= 25 ) { $t = 15; } // floor( 200 / 8)\n            else if ($length >= 18 ) { $t = 18; } // floor( 150 / 8)\n            else                     { $t = 27; }\n            // @codingStandardsIgnoreEnd\n        }\n\n        // ie. gmp_testbit($this, 0)\n        // ie. isEven() or !isOdd()\n        switch ( MATH_BIGINTEGER_MODE ) {\n            case MATH_BIGINTEGER_MODE_GMP:\n                return gmp_prob_prime($this->value, $t) != 0;\n            case MATH_BIGINTEGER_MODE_BCMATH:\n                if ($this->value === '2') {\n                    return true;\n                }\n                if ($this->value[strlen($this->value) - 1] % 2 == 0) {\n                    return false;\n                }\n                break;\n            default:\n                if ($this->value == array(2)) {\n                    return true;\n                }\n                if (~$this->value[0] & 1) {\n                    return false;\n                }\n        }\n\n        static $primes, $zero, $one, $two;\n\n        if (!isset($primes)) {\n            $primes = array(\n                3,    5,    7,    11,   13,   17,   19,   23,   29,   31,   37,   41,   43,   47,   53,   59,\n                61,   67,   71,   73,   79,   83,   89,   97,   101,  103,  107,  109,  113,  127,  131,  137,\n                139,  149,  151,  157,  163,  167,  173,  179,  181,  191,  193,  197,  199,  211,  223,  227,\n                229,  233,  239,  241,  251,  257,  263,  269,  271,  277,  281,  283,  293,  307,  311,  313,\n                317,  331,  337,  347,  349,  353,  359,  367,  373,  379,  383,  389,  397,  401,  409,  419,\n                421,  431,  433,  439,  443,  449,  457,  461,  463,  467,  479,  487,  491,  499,  503,  509,\n                521,  523,  541,  547,  557,  563,  569,  571,  577,  587,  593,  599,  601,  607,  613,  617,\n                619,  631,  641,  643,  647,  653,  659,  661,  673,  677,  683,  691,  701,  709,  719,  727,\n                733,  739,  743,  751,  757,  761,  769,  773,  787,  797,  809,  811,  821,  823,  827,  829,\n                839,  853,  857,  859,  863,  877,  881,  883,  887,  907,  911,  919,  929,  937,  941,  947,\n                953,  967,  971,  977,  983,  991,  997\n            );\n\n            if ( MATH_BIGINTEGER_MODE != MATH_BIGINTEGER_MODE_INTERNAL ) {\n                for ($i = 0; $i < count($primes); ++$i) {\n                    $primes[$i] = new Math_BigInteger($primes[$i]);\n                }\n            }\n\n            $zero = new Math_BigInteger();\n            $one = new Math_BigInteger(1);\n            $two = new Math_BigInteger(2);\n        }\n\n        if ($this->equals($one)) {\n            return false;\n        }\n\n        // see HAC 4.4.1 \"Random search for probable primes\"\n        if ( MATH_BIGINTEGER_MODE != MATH_BIGINTEGER_MODE_INTERNAL ) {\n            foreach ($primes as $prime) {\n                list(, $r) = $this->divide($prime);\n                if ($r->equals($zero)) {\n                    return $this->equals($prime);\n                }\n            }\n        } else {\n            $value = $this->value;\n            foreach ($primes as $prime) {\n                list(, $r) = $this->_divide_digit($value, $prime);\n                if (!$r) {\n                    return count($value) == 1 && $value[0] == $prime;\n                }\n            }\n        }\n\n        $n   = $this->copy();\n        $n_1 = $n->subtract($one);\n        $n_2 = $n->subtract($two);\n\n        $r = $n_1->copy();\n        $r_value = $r->value;\n        // ie. $s = gmp_scan1($n, 0) and $r = gmp_div_q($n, gmp_pow(gmp_init('2'), $s));\n        if ( MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_BCMATH ) {\n            $s = 0;\n            // if $n was 1, $r would be 0 and this would be an infinite loop, hence our $this->equals($one) check earlier\n            while ($r->value[strlen($r->value) - 1] % 2 == 0) {\n                $r->value = bcdiv($r->value, '2', 0);\n                ++$s;\n            }\n        } else {\n            for ($i = 0, $r_length = count($r_value); $i < $r_length; ++$i) {\n                $temp = ~$r_value[$i] & 0xFFFFFF;\n                for ($j = 1; ($temp >> $j) & 1; ++$j);\n                if ($j != 25) {\n                    break;\n                }\n            }\n            $s = 26 * $i + $j - 1;\n            $r->_rshift($s);\n        }\n\n        for ($i = 0; $i < $t; ++$i) {\n            $a = $this->random($two, $n_2);\n            $y = $a->modPow($r, $n);\n\n            if (!$y->equals($one) && !$y->equals($n_1)) {\n                for ($j = 1; $j < $s && !$y->equals($n_1); ++$j) {\n                    $y = $y->modPow($two, $n);\n                    if ($y->equals($one)) {\n                        return false;\n                    }\n                }\n\n                if (!$y->equals($n_1)) {\n                    return false;\n                }\n            }\n        }\n        return true;\n    }\n\n    /**\n     * Logical Left Shift\n     *\n     * Shifts BigInteger's by $shift bits.\n     *\n     * @param Integer $shift\n     * @access private\n     */\n    function _lshift($shift)\n    {\n        if ( $shift == 0 ) {\n            return;\n        }\n\n        $num_digits = (int) ($shift / MATH_BIGINTEGER_BASE);\n        $shift %= MATH_BIGINTEGER_BASE;\n        $shift = 1 << $shift;\n\n        $carry = 0;\n\n        for ($i = 0; $i < count($this->value); ++$i) {\n            $temp = $this->value[$i] * $shift + $carry;\n            $carry = (int) ($temp / MATH_BIGINTEGER_BASE_FULL);\n            $this->value[$i] = (int) ($temp - $carry * MATH_BIGINTEGER_BASE_FULL);\n        }\n\n        if ( $carry ) {\n            $this->value[] = $carry;\n        }\n\n        while ($num_digits--) {\n            array_unshift($this->value, 0);\n        }\n    }\n\n    /**\n     * Logical Right Shift\n     *\n     * Shifts BigInteger's by $shift bits.\n     *\n     * @param Integer $shift\n     * @access private\n     */\n    function _rshift($shift)\n    {\n        if ($shift == 0) {\n            return;\n        }\n\n        $num_digits = (int) ($shift / MATH_BIGINTEGER_BASE);\n        $shift %= MATH_BIGINTEGER_BASE;\n        $carry_shift = MATH_BIGINTEGER_BASE - $shift;\n        $carry_mask = (1 << $shift) - 1;\n\n        if ( $num_digits ) {\n            $this->value = array_slice($this->value, $num_digits);\n        }\n\n        $carry = 0;\n\n        for ($i = count($this->value) - 1; $i >= 0; --$i) {\n            $temp = $this->value[$i] >> $shift | $carry;\n            $carry = ($this->value[$i] & $carry_mask) << $carry_shift;\n            $this->value[$i] = $temp;\n        }\n\n        $this->value = $this->_trim($this->value);\n    }\n\n    /**\n     * Normalize\n     *\n     * Removes leading zeros and truncates (if necessary) to maintain the appropriate precision\n     *\n     * @param Math_BigInteger\n     * @return Math_BigInteger\n     * @see _trim()\n     * @access private\n     */\n    function _normalize($result)\n    {\n        $result->precision = $this->precision;\n        $result->bitmask = $this->bitmask;\n\n        switch ( MATH_BIGINTEGER_MODE ) {\n            case MATH_BIGINTEGER_MODE_GMP:\n                if (!empty($result->bitmask->value)) {\n                    $result->value = gmp_and($result->value, $result->bitmask->value);\n                }\n\n                return $result;\n            case MATH_BIGINTEGER_MODE_BCMATH:\n                if (!empty($result->bitmask->value)) {\n                    $result->value = bcmod($result->value, $result->bitmask->value);\n                }\n\n                return $result;\n        }\n\n        $value = &$result->value;\n\n        if ( !count($value) ) {\n            return $result;\n        }\n\n        $value = $this->_trim($value);\n\n        if (!empty($result->bitmask->value)) {\n            $length = min(count($value), count($this->bitmask->value));\n            $value = array_slice($value, 0, $length);\n\n            for ($i = 0; $i < $length; ++$i) {\n                $value[$i] = $value[$i] & $this->bitmask->value[$i];\n            }\n        }\n\n        return $result;\n    }\n\n    /**\n     * Trim\n     *\n     * Removes leading zeros\n     *\n     * @param Array $value\n     * @return Math_BigInteger\n     * @access private\n     */\n    function _trim($value)\n    {\n        for ($i = count($value) - 1; $i >= 0; --$i) {\n            if ( $value[$i] ) {\n                break;\n            }\n            unset($value[$i]);\n        }\n\n        return $value;\n    }\n\n    /**\n     * Array Repeat\n     *\n     * @param $input Array\n     * @param $multiplier mixed\n     * @return Array\n     * @access private\n     */\n    function _array_repeat($input, $multiplier)\n    {\n        return ($multiplier) ? array_fill(0, $multiplier, $input) : array();\n    }\n\n    /**\n     * Logical Left Shift\n     *\n     * Shifts binary strings $shift bits, essentially multiplying by 2**$shift.\n     *\n     * @param $x String\n     * @param $shift Integer\n     * @return String\n     * @access private\n     */\n    function _base256_lshift(&$x, $shift)\n    {\n        if ($shift == 0) {\n            return;\n        }\n\n        $num_bytes = $shift >> 3; // eg. floor($shift/8)\n        $shift &= 7; // eg. $shift % 8\n\n        $carry = 0;\n        for ($i = strlen($x) - 1; $i >= 0; --$i) {\n            $temp = ord($x[$i]) << $shift | $carry;\n            $x[$i] = chr($temp);\n            $carry = $temp >> 8;\n        }\n        $carry = ($carry != 0) ? chr($carry) : '';\n        $x = $carry . $x . str_repeat(chr(0), $num_bytes);\n    }\n\n    /**\n     * Logical Right Shift\n     *\n     * Shifts binary strings $shift bits, essentially dividing by 2**$shift and returning the remainder.\n     *\n     * @param $x String\n     * @param $shift Integer\n     * @return String\n     * @access private\n     */\n    function _base256_rshift(&$x, $shift)\n    {\n        if ($shift == 0) {\n            $x = ltrim($x, chr(0));\n            return '';\n        }\n\n        $num_bytes = $shift >> 3; // eg. floor($shift/8)\n        $shift &= 7; // eg. $shift % 8\n\n        $remainder = '';\n        if ($num_bytes) {\n            $start = $num_bytes > strlen($x) ? -strlen($x) : -$num_bytes;\n            $remainder = substr($x, $start);\n            $x = substr($x, 0, -$num_bytes);\n        }\n\n        $carry = 0;\n        $carry_shift = 8 - $shift;\n        for ($i = 0; $i < strlen($x); ++$i) {\n            $temp = (ord($x[$i]) >> $shift) | $carry;\n            $carry = (ord($x[$i]) << $carry_shift) & 0xFF;\n            $x[$i] = chr($temp);\n        }\n        $x = ltrim($x, chr(0));\n\n        $remainder = chr($carry >> $carry_shift) . $remainder;\n\n        return ltrim($remainder, chr(0));\n    }\n\n    // one quirk about how the following functions are implemented is that PHP defines N to be an unsigned long\n    // at 32-bits, while java's longs are 64-bits.\n\n    /**\n     * Converts 32-bit integers to bytes.\n     *\n     * @param Integer $x\n     * @return String\n     * @access private\n     */\n    function _int2bytes($x)\n    {\n        return ltrim(pack('N', $x), chr(0));\n    }\n\n    /**\n     * Converts bytes to 32-bit integers\n     *\n     * @param String $x\n     * @return Integer\n     * @access private\n     */\n    function _bytes2int($x)\n    {\n        $temp = unpack('Nint', str_pad($x, 4, chr(0), STR_PAD_LEFT));\n        return $temp['int'];\n    }\n\n    /**\n     * DER-encode an integer\n     *\n     * The ability to DER-encode integers is needed to create RSA public keys for use with OpenSSL\n     *\n     * @see modPow()\n     * @access private\n     * @param Integer $length\n     * @return String\n     */\n    function _encodeASN1Length($length)\n    {\n        if ($length <= 0x7F) {\n            return chr($length);\n        }\n\n        $temp = ltrim(pack('N', $length), chr(0));\n        return pack('Ca*', 0x80 | strlen($temp), $temp);\n    }\n}"
  },
  {
    "path": "api/v2/MusicAPI.php",
    "content": "<?php\n\n/**\n * Netease Cloud Music Api\n * @Version 2.1.1\n * @auther METO, Axhello\n * @description 推荐使用php5.5以上\n * Released under the MIT license\n */\n\nrequire dirname(__FILE__) . '/BigInteger.php';\n\nclass MusicAPI\n{\n    const MODULUS = '00e0b509f6259df8642dbc35662901477df22677ec152b5ff68ace615bb7b725152b3ab17a876aea8a5aa76d2e417629ec4ee341f56135fccf695280104e0312ecbda92557c93870114af6c9d05c4f7f0c3685b7a46bee255932575cce10b424d813cfe4875d3e82047b97ddef52741d546b8e289dc6935b3ece0462db0a22b8e7';\n    const NONCE = '0CoJUm6Qyw8W8jud';\n    const PUBKEY = '010001';\n    protected $headers = ['Accept: */*', 'Accept-Encoding: gzip,deflate,sdch', 'Accept-Language: zh-CN,zh;q=0.8,gl;q=0.6,zh-TW;q=0.4', 'Connection: keep-alive', 'Content-Type: application/x-www-form-urlencoded', 'Host: music.163.com', 'Referer: http://music.163.com/search/', 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36'];\n    protected $secretKey;\n\n    public function __construct()\n    {\n        $this->secretKey = $this->createSecretKey(16);\n    }\n\n    protected function createSecretKey($length)\n    {\n        $str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';\n        $r = '';\n        for ($i = 0; $i < $length; $i++) {\n            $r .= $str[rand(0, strlen($str) - 1)];\n        }\n        return $r;\n    }\n\n    protected function prepare($data)\n    {\n        $data['params'] = $this->aesEncrypt($data['params'], self::NONCE);\n        $data['params'] = $this->aesEncrypt($data['params'], $this->secretKey);\n        $data['encSecKey'] = $this->rsaEncrypt($this->secretKey);\n        return $data;\n    }\n\n    protected function aesEncrypt($secretData, $secret)\n    {\n        return openssl_encrypt($secretData, 'aes-128-cbc', $secret, false, '0102030405060708');\n    }\n\n    /**\n     * @param $text\n     * @return string\n     */\n    protected function rsaEncrypt($text)\n    {\n        $rtext = strrev(utf8_encode($text));\n        $keytext = $this->bchexdec($this->strToHex($rtext));\n        $biText = new Math_BigInteger($keytext);\n        $biKey = new Math_BigInteger($this->bchexdec(self::PUBKEY));\n        $biMod = new Math_BigInteger($this->bchexdec(self::MODULUS));\n        $key = $biText->modPow($biKey, $biMod)->toHex();\n        return str_pad($key, 256, '0', STR_PAD_LEFT);\n    }\n\n    protected function bchexdec($hex)\n    {\n        $dec = 0;\n        $len = strlen($hex);\n        for ($i = 0; $i < $len; $i++) {\n            $dec = bcadd($dec, bcmul(strval(hexdec($hex[$i])), bcpow('16', strval($len - $i - 1))));\n        }\n        return $dec;\n    }\n\n    protected function strToHex($str)\n    {\n        $hex = '';\n        for ($i = 0; $i < strlen($str); $i++) {\n            $hex .= dechex(ord($str[$i]));\n        }\n        return $hex;\n    }\n\n    protected function curl($url, $data = null)\n    {\n        $curl = curl_init();\n        curl_setopt($curl, CURLOPT_URL, $url);\n        if ($data) {\n            if (is_array($data)) $data = http_build_query($data);\n            curl_setopt($curl, CURLOPT_POSTFIELDS, $data);\n            curl_setopt($curl, CURLOPT_POST, 1);\n        }\n        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);\n        curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);\n        curl_setopt($curl, CURLOPT_REFERER, 'http://music.163.com/');\n        curl_setopt($curl, CURLOPT_HTTPHEADER, $this->headers);\n        curl_setopt($curl, CURLOPT_ENCODING, 'application/json');\n        $result = curl_exec($curl);\n        curl_close($curl);\n        return $result;\n    }\n\n    /**\n     * 搜索API\n     * @param $s 要搜索的内容\n     * @param $limit 要返回的条数\n     * @param $offset 设置偏移量 用于分页\n     * @param $type 类型 [1 单曲] [10 专辑] [100 歌手] [1000 歌单] [1002 用户]\n     * @return JSON\n     */\n    public function search($s = null, $limit = 30, $offset = 0, $type = 1)\n    {\n        $url = 'http://music.163.com/weapi/cloudsearch/get/web?csrf_token=';\n        $data = ['params' => '{\n              \"s\":\"' . $s . '\",\n              \"type\":\"' . $type . '\",\n              \"limit\":\"' . $limit . '\",\n              \"total\":\"true\",\n              \"offset\":\"' . $offset . '\",\n              \"csrf_token\": \"\"\n          }'];\n        return $this->curl($url, $this->prepare($data));\n    }\n\n    /**\n     * 歌曲详情API，不带MP3链接\n     * @param $song_id 歌曲id\n     * @return JSON\n     */\n    public function detail($song_id)\n    {\n        $url = 'http://music.163.com/weapi/v1/song/detail';\n        if (is_array($song_id)) $s = '[\"' . implode('\",\"', $song_id) . '\"]'; else $s = '[\"' . $song_id . '\"]';\n        $data = ['params' => '{\n                \"ids\":' . $s . ',\n                \"csrf_token\":\"\"\n            }'];\n        return $this->curl($url, $this->prepare($data));\n    }\n\n    /**\n     * 新版API歌曲链接不包含在歌曲详情API里,通过此API获取\n     * @param $song_id\n     * @param int $br\n     * @return JSON\n     */\n    public function mp3url($song_id, $br = 320000)\n    {\n        $url = 'http://music.163.com/weapi/song/enhance/player/url?csrf_token=';\n        if (is_array($song_id)) $s = '[\"' . implode('\",\"', $song_id) . '\"]'; else $s = '[\"' . $song_id . '\"]';\n        $data = ['params' => '{\n                \"ids\":' . $s . ',\n                \"br\":\"' . $br . '\",\n                \"csrf_token\":\"\"\n            }'];\n        return $this->curl($url, $this->prepare($data));\n    }\n\n    /**\n     * 歌词API 增加了几个字段\n     * @param $song_id\n     * @return JSON\n     */\n    public function lyric($song_id)\n    {\n        $url = 'http://music.163.com/weapi/song/lyric?csrf_token=';\n        $data = ['params' => '{\n                \"id\":\"' . $song_id . '\",\n                \"os\":\"pc\",\n                \"lv\":\"-1\",\n                \"kv\":\"-1\",\n                \"tv\":\"-1\",\n                \"csrf_token\":\"\"\n            }'];\n        return $this->curl($url, $this->prepare($data));\n    }\n\n    /**\n     * 歌单API\n     * @param $playlist_id\n     * @return JSON\n     */\n    public function playlist($playlist_id)\n    {\n        $url = 'http://music.163.com/weapi/v3/playlist/detail?csrf_token=';\n        $data = ['params' => '{\n                \"id\":\"' . $playlist_id . '\",\n                \"n\":\"1000\",\n                \"csrf_token\":\"\"\n            }'];\n        return $this->curl($url, $this->prepare($data));\n    }\n\n    /**\n     * 根据MVid(如果有)获取MV链接\n     * @param $mv_id\n     * @return JSON\n     */\n    public function mv($mv_id)\n    {\n        $url = 'http://music.163.com/weapi/mv/detail/';\n        $data = ['params' => '{\n                \"id\":\"' . $mv_id . '\",\n                \"csrf_token\":\"\"\n            }'];\n        return $this->curl($url, $this->prepare($data));\n    }\n\n}"
  },
  {
    "path": "dist/fonts/themicons.css",
    "content": "@font-face {\n    font-family: \"themicons\";\n    src: url(\"themicons.eot\"); /* IE9 */\n    src: url(\"themicons.eot?#iefix\") format(\"embedded-opentype\"), /* IE6-IE8 */\n    url(\"themicons.woff\") format(\"woff\"), /* chrome, firefox */\n    url(\"themicons.ttf\") format(\"truetype\"), /* chrome, firefox, opera, Safari, Android, iOS 4.2+ */\n    url(\"themicons.svg#themicons\") format(\"svg\"); /* iOS 4.1- */\n    font-style: normal;\n    font-weight: normal;\n}\n\n\n"
  },
  {
    "path": "gulpfile.js",
    "content": "var gulp = require('gulp'),\n    minifycss = require('gulp-minify-css'),\n    concat = require('gulp-concat'),\n    rename = require('gulp-rename'),\n    uglify = require('gulp-uglify'),\n    fontmin = require('gulp-fontmin');\n \n//压缩css\ngulp.task('minifycss', function() {\n    return gulp.src('src/css/*.css') //需要操作的文件\n        .pipe(rename({ suffix: '.min' })) //rename压缩后的文件名\n        .pipe(minifycss()) //执行压缩\n        .pipe(gulp.dest('dist/css')); //输出文件夹\n});\n//压缩js  \ngulp.task('scripts', function() {\n    return gulp.src(['src/js/vue.min.js', 'src/js/vue-resource.min.js', 'src/js/vplayer.js'])\n        .pipe(concat('app.js'))\n        .pipe(rename({ suffix: '.min' }))\n        .pipe(uglify())\n        .pipe(gulp.dest('dist/js'));\n});\n\n//压缩图标字体\ngulp.task('fontmin', function () {\n    return gulp.src('src/fonts/*.ttf')\n        .pipe(fontmin())\n        .pipe(gulp.dest('dist/fonts'));\n});\n\n//gulp watch\ngulp.task('watch', function () {  \n   gulp.watch('src/css/*.css', ['minifycss']);  \n   gulp.watch('src/js/*.js', ['scripts']);  \n});\n"
  },
  {
    "path": "index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"zh-cn\">\n\n<head>\n  <meta charset=\"utf-8\">\n  <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n  <meta name=\"keywords\" content=\"vPlayer,vuejs,播放器,网易云api\" />\n  <meta name=\"description\" content=\"用vuejs+网易云api写的一款在线播放器\">\n  <meta name=\"author\" content=\"vPlayer\">\n  <title>vPlayer</title>\n  <link rel=\"stylesheet\" type=\"text/css\" href=\"dist/css/vplayer.min.css\">\n</head>\n\n<body>\n  <div id=\"app\" class=\"home page page-template-landing\" :class=\"{'site-player-is-open':listOpen}\">\n    <div id=\"viewport-panel\">\n      <div id=\"page\" class=\"hfeed site\">\n        <header class=\"site-header\" :style=\"{ backgroundImage: 'url('+ playingPic +')' }\">\n          <div id=\"lyricWrapper\" class=\"site-branding\">\n            <div v-show=\"lyric.length != 0\" id=\"lyricContainer\">\n              <p v-for=\"(lrc, index) in lyric\" :id=\"'line-'+index\">{{lrc[1]}}</p>\n            </div>\n            <div v-text=\"lyricText\" class=\"lyric-description\"></div>\n          </div>\n        </header>\n        <div id=\"content\" class=\"site-content\">\n          <main id=\"primary\" class=\"content-area\">\n            <div id=\"post\" class=\"post page type-page status-publish hentry\">\n              <div class=\"entry\">\n                <div class=\"entry-header\">\n                  <h1 class=\"entry-title\">New Song!</h1>\n                </div>\n                <div class=\"entry-content\">\n                  <p class=\"content\">Enjoy music from NetEaseCloud!</p>\n                  <p class=\"btn\" :class=\"{'expand': goSearch}\">\n                    <a class=\"button\" href=\"#\" @click=\"goSearch\">Let's Go</a>\n                  </p>\n                </div>\n                <div class=\"form-table\" :class=\"{'insearch': goSearch}\">\n                  <form action=\"\" @submit.prevent>\n                    <div class=\"input-group\">\n                      <input type=\"text\" @keyup.enter=\"formSubmit\" @blur=\"formSubmit\" class=\"form-control\" name=\"search\" placeholder=\"试试输入“Tobu”\" autocomplete=\"off\" v-model=\"search\">\n                    </div>\n                  </form>\n                </div>\n              </div>\n              <div class=\"table-example\" :class=\"{'insearch': goSearch}\">\n                <table class=\"table is-striped\">\n                  <thead v-show=\"isSearch\">\n                    <tr>\n                      <th class=\"jin\">#</th>\n                      <th>歌曲名</th>\n                      <th>歌手</th>\n                      <th>专辑</th>\n                    </tr>\n                  </thead>\n                  <tbody>\n                    <tr v-for=\"list in songLists\" @click=\"playMusic(list.id)\">\n                      <td>\n                        <i class=\"is-playable\"></i>\n                      </td>\n                      <td>{{ list.name }}</td>\n                      <td>\n                        <span v-if=\"list.ar.length >= 1\">{{list.ar[0].name}}</span>\n                        <span v-if=\"list.ar.length >= 2\">/ {{list.ar[1].name}}</span>\n                        <span v-if=\"list.ar.length >= 3\">/ {{list.ar[2].name}}</span>\n                        <span v-if=\"list.ar.length >= 4\">/ {{list.ar[3].name}}</span>\n                        <span v-if=\"list.ar.length >= 5\">/ {{list.ar[4].name}}</span>\n                      </td>\n                      <td>{{ '《' +list.al.name+ '》'}}</td>\n                    </tr>\n                  </tbody>\n                </table>\n                <nav style=\"margin-bottom: 3em;\">\n                  <ul class=\"pager\">\n                    <li v-show=\"pages != 0\">\n                      <a href=\"#\" @click=\"prevPage\">上一页</a>\n                    </li>\n                    <li v-show=\"isSearch\">\n                      <a href=\"#\" @click=\"nextPage\">下一页</a>\n                    </li>\n                  </ul>\n                </nav>\n              </div>\n            </div>\n          </main>\n        </div>\n      </div>\n    </div>\n    <button id=\"site-player-toggle\" class=\"site-player-toggle\" :class=\"{'is-open':listOpen}\" @click=\"isListOpen\">Toggle Player</button>\n    <div id=\"site-player-panel\" class=\"site-player-panel\">\n      <div class=\"site-player tracks-count-8 is-shuffling is-playing\">\n        <div class=\"controls\">\n          <button class=\"previous\" @click=\"prevPlay\" title=\"上一首\">上一首</button>\n          <button class=\"play-pause\" @click=\"setPlay(playingId)\" :class=\"[ isPlay ? 'pause' : 'play']\" title=\"播放/暂停\">播放/暂停</button>\n          <button class=\"next\" @click=\"nextPlay\" title=\"下一首\">下一首</button>\n          <button class=\"repeat\" :class=\"{'is-active': isActive}\" title=\"单曲循环\" @click=\"setLoop\">单曲循环</button>\n          <button class=\"shuffle\" title=\"随机播放\" @click=\"setRandom\">随机播放</button>\n          <div class=\"progress-bar\" @click=\"clickProgress\">\n            <div class=\"play-bar\" :style=\"{ width: progress+'%'}\"></div>\n            <div class=\"play-point\"></div>\n          </div>\n          <div class=\"times\">\n            <span class=\"current-time\">{{ showCurrentTime }}</span> /\n            <span class=\"duration\">{{ showDurationTime }}</span>\n          </div>\n          <div class=\"volume-panel\">\n            <button class=\"volume-toggle\" :class=\"{'is-muted': isMuted}\" @click=\"setMuted\" title=\"静音\">静音</button>\n            <input v-model=\"range\" @change=\"setVolume\" type=\"range\" min=\"0\" max=\"1\" step=\"0.1\" :value=\"range\">\n          </div>\n        </div>\n        <div class=\"playlist\">\n          <ol class=\"tracks-list\">\n            <li class=\"track\" v-for=\"(paly, index) in playingLists\" :class=\"{'is-current is-playing': currentIndex == index && isPlay}\">\n              <span class=\"track-status track-cell\"></span>\n              <span class=\"track-details track-cell\" @click=\"playHistoryList(paly.id, index)\">\n                <span class=\"track-title\">{{ paly.title }}</span>\n                <span class=\"track-artist\">{{ paly.artists }}</span>\n              </span>\n              <span class=\"track-actions track-cell\"></span>\n              <span @click=\"removeList(index)\" class=\"track-length track-cell\">X</span>\n            </li>\n          </ol>\n        </div>\n      </div>\n    </div>\n    <div class=\"site-current-track-details\">\n      <span class=\"title\">{{ playingTitle }}</span> -\n      <span class=\"artist\">{{ playingArtist }}</span>\n      <div class=\"times\">\n        <span class=\"current-time\">{{ showCurrentTime }}</span> /\n        <span class=\"duration\">{{ showDurationTime }}</span>\n      </div>\n    </div>\n    <button class=\"site-play-pause-button\" :class=\"[ isPlay ? 'pause' : 'play']\" @click=\"setPlay(playingId)\" title=\"播放/暂停\">播放/暂停</button>\n  </div>\n  <script src=\"dist/js/app.min.js\" charset=\"utf-8\"></script>\n</body>\n\n</html>\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"vPlayer\",\n  \"version\": \"1.0.0\",\n  \"description\": \"用vuejs写的播放器，API基于网易云, 具体效果请查看Demo\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/axhello/vPlayer.git\"\n  },\n  \"keywords\": [],\n  \"author\": \"Axhello\",\n  \"license\": \"MIT\",\n  \"bugs\": {\n    \"url\": \"https://github.com/axhello/vPlayer/issues\"\n  },\n  \"homepage\": \"https://github.com/axhello/vPlayer#readme\",\n  \"devDependencies\": {\n    \"gulp\": \"^3.9.1\",\n    \"gulp-concat\": \"^2.6.0\",\n    \"gulp-fontmin\": \"^0.7.4\",\n    \"gulp-iconfont\": \"^8.0.1\",\n    \"gulp-minify-css\": \"^1.2.4\",\n    \"gulp-rename\": \"^1.2.2\",\n    \"gulp-uglify\": \"^2.0.0\"\n  }\n}\n"
  },
  {
    "path": "src/css/vplayer.css",
    "content": "/**\n * normalize.css v3.0.2 | MIT License | git.io/normalize\n * -----------------------------------------------------------------------------\n */\n\nhtml {\n    -webkit-text-size-adjust: 100%;\n    -ms-text-size-adjust: 100%;\n}\n\n#app {\n    width: 100%;\n    height: 100%;\n}\n\n@font-face {\n    font-family: \"themicons\";\n    src: url(\"../fonts/themicons.eot\") format(\"eot\"), url(\"../fonts/themicons.woff\") format(\"woff\"), url(\"../fonts/themicons.ttf\") format(\"truetype\");\n    font-weight: normal;\n    font-style: normal;\n}\n\n.themicon {\n    display: inline-block;\n    font-family: \"themicons\";\n    font-size: 16px;\n    font-style: normal;\n    font-weight: normal;\n    line-height: 1;\n    speak: none;\n    text-decoration: inherit;\n    text-transform: none;\n    vertical-align: middle;\n    -moz-osx-font-smoothing: grayscale;\n    -webkit-font-smoothing: antialiased;\n}\n\nbody {\n    margin: 0;\n}\n\narticle,\naside,\ndetails,\nfigcaption,\nfigure,\nfooter,\nheader,\nhgroup,\nmain,\nmenu,\nnav,\nsection,\nsummary {\n    display: block;\n}\n\naudio,\ncanvas,\nprogress,\nvideo {\n    display: inline-block;\n    vertical-align: baseline;\n}\n\naudio:not([controls]) {\n    display: none;\n    height: 0;\n}\n\n[hidden],\ntemplate {\n    display: none;\n}\n\na {\n    background-color: transparent;\n}\n\na:active,\na:hover {\n    outline: 0;\n}\n\nabbr[title] {\n    border-bottom: 1px dotted;\n}\n\nb,\nstrong {\n    font-weight: bold;\n}\n\ndfn {\n    font-style: italic;\n}\n\nh1 {\n    font-size: 2em;\n    margin: 0.67em 0;\n}\n\nmark {\n    background: #ff0;\n    color: #000;\n}\n\nsmall {\n    font-size: 80%;\n}\n\nsub,\nsup {\n    font-size: 75%;\n    line-height: 0;\n    position: relative;\n    vertical-align: baseline;\n}\n\nsup {\n    top: -0.5em;\n}\n\nsub {\n    bottom: -0.25em;\n}\n\nimg {\n    border: 0;\n}\n\nsvg:not(:root) {\n    overflow: hidden;\n}\n\nfigure {\n    margin: 1em 40px;\n}\n\nhr {\n    -moz-box-sizing: content-box;\n    box-sizing: content-box;\n    height: 0;\n}\n\npre {\n    overflow: auto;\n}\n\ncode,\nkbd,\npre,\nsamp {\n    font-family: monospace, monospace;\n    font-size: 1em;\n}\n\nbutton,\ninput,\noptgroup,\nselect,\ntextarea {\n    color: inherit;\n    font: inherit;\n    margin: 0;\n}\n\nbutton {\n    overflow: visible;\n}\n\nbutton,\nselect {\n    text-transform: none;\n}\n\nbutton,\nhtml input[type=\"button\"],\ninput[type=\"reset\"],\ninput[type=\"submit\"] {\n    cursor: pointer;\n    -webkit-appearance: button;\n}\n\nbutton[disabled],\nhtml input[disabled] {\n    cursor: default;\n}\n\nbutton::-moz-focus-inner,\ninput::-moz-focus-inner {\n    border: 0;\n    padding: 0;\n}\n\ninput {\n    line-height: normal;\n}\n\ninput[type=\"checkbox\"],\ninput[type=\"radio\"] {\n    -moz-box-sizing: border-box;\n    box-sizing: border-box;\n    padding: 0;\n}\n\ninput[type=\"number\"]::-webkit-inner-spin-button,\ninput[type=\"number\"]::-webkit-outer-spin-button {\n    height: auto;\n}\n\ninput[type=\"search\"] {\n    -moz-box-sizing: content-box;\n    box-sizing: content-box;\n    -webkit-appearance: textfield;\n}\n\ninput[type=\"search\"]::-webkit-search-cancel-button,\ninput[type=\"search\"]::-webkit-search-decoration {\n    -webkit-appearance: none;\n}\n\nfieldset {\n    border: 1px solid #c0c0c0;\n    margin: 0 2px;\n    padding: 0.35em 0.625em 0.75em;\n}\n\nlegend {\n    border: 0;\n    padding: 0;\n}\n\ntextarea {\n    overflow: auto;\n}\n\noptgroup {\n    font-weight: bold;\n}\n\ntable {\n    border-collapse: collapse;\n    border-spacing: 0;\n}\n\ntd,\nth {\n    padding: 0;\n}\n\n/**\n * Typography\n * -----------------------------------------------------------------------------\n */\n\n\nbody {\n    color: #333;\n    font-family: \"Helvetica Neue\",Helvetica,Arial,sans-serif;\n    font-size: 14px;\n    line-height: 1.42857143;\n    color: #333;\n}\nbody {\n    font-family: \"Helvetica Neue\",Helvetica,Arial,\"Hiragino Sans GB\",\"Hiragino Sans GB W3\",\"WenQuanYi Micro Hei\",sans-serif;\n}\n\nbutton,\ninput,\nselect,\ntextarea,\n.button {\n    font-family: \"Roboto\", sans-serif;\n}\n\nh1,\nh2,\nh3,\nh4,\nh5,\nh6 {\n    clear: both;\n    color: #333;\n    font-family: \"Noto Serif\", serif;\n    -moz-osx-font-smoothing: grayscale;\n    font-weight: 700;\n    margin: 0;\n    text-rendering: optimizeLegibility;\n}\n\nh1 {\n    font-size: 30px;\n    font-size: 3rem;\n    line-height: 1.25;\n    margin: 0.66666667em 0;\n}\n\nh2 {\n    font-size: 24px;\n    font-size: 2.4rem;\n    line-height: 1.25;\n    margin: 1em 0;\n}\n\nh3 {\n    font-size: 20px;\n    font-size: 2rem;\n    line-height: 1.25;\n    margin: 1.33333333em 0;\n}\n\nh4 {\n    font-size: 15px;\n    font-size: 1.5rem;\n    letter-spacing: 0.1em;\n    line-height: 1.25;\n    margin: 1.33333333em 0;\n    text-transform: uppercase;\n}\n\nh5 {\n    font-size: 13px;\n    font-size: 1.3rem;\n    letter-spacing: 0.1em;\n    line-height: 1.25;\n    margin: 1.33333333em 0;\n    text-transform: uppercase;\n}\n\nh6 {\n    font-size: 11px;\n    font-size: 1.1rem;\n    letter-spacing: 0.1em;\n    line-height: 1.25;\n    margin: 1.81818182em 0;\n    text-transform: uppercase;\n}\n\nb,\nstrong {\n    font-weight: 700;\n}\n\ndfn,\ncite,\nem,\ni {\n    font-style: italic;\n}\n\nblockquote {\n    background-color: #f7f7f7;\n    border: solid #dedede;\n    border-width: 1px 0;\n    color: #555;\n    margin-bottom: 1.7em;\n    margin-left: 0;\n    margin-right: 0;\n    padding: 1.33333333em;\n}\n\nblockquote blockquote {\n    border-width: 0;\n    padding-bottom: 0;\n    padding-top: 0;\n}\n\nblockquote p:last-child {\n    margin-bottom: 0;\n}\n\nblockquote cite,\nblockquote small {\n    color: #333;\n    font-size: 15px;\n    font-size: 1.5rem;\n}\n\nblockquote cite {\n    display: block;\n    margin-top: 0.66666667em;\n}\n\naddress {\n    font-style: italic;\n    margin: 0 0 1.7em;\n}\n\ncode,\nkbd,\ntt,\nvar,\nsamp,\npre {\n    font-family: \"Menlo\", \"Monaco\", \"Consolas\", \"Courier New\", monospace;\n    -moz-hyphens: none;\n    -webkit-hyphens: none;\n    hyphens: none;\n    -ms-hyphens: none;\n}\n\npre {\n    background-color: transparent;\n    background-color: rgba(0, 0, 0, 0.01);\n    border: 1px solid #dedede;\n    line-height: 1.2;\n    margin-bottom: 1.7em;\n    max-width: 100%;\n    overflow: auto;\n    padding: 0.8em;\n    white-space: pre;\n    white-space: pre-wrap;\n    word-wrap: break-word;\n}\n\nabbr[title] {\n    border-bottom: 1px dotted #dedede;\n    cursor: help;\n}\n\nmark,\nins {\n    background-color: #fff9c0;\n    text-decoration: none;\n}\n\nsup,\nsub {\n    font-size: 75%;\n    height: 0;\n    line-height: 0;\n    position: relative;\n    vertical-align: baseline;\n}\n\nsup {\n    bottom: 1ex;\n}\n\nsub {\n    top: 0.5ex;\n}\n\nsmall {\n    font-size: 75%;\n}\n\nbig {\n    font-size: 125%;\n}\n\n\n/**\n * Elements\n * -----------------------------------------------------------------------------\n */\n\n*,\n*:before,\n*:after {\n    -moz-box-sizing: inherit;\n    box-sizing: inherit;\n}\n\nhtml {\n    -moz-box-sizing: border-box;\n    box-sizing: border-box;\n    font-size: 62.5%;\n}\n\nbody {\n    background-color: #fff;\n}\n\nhr {\n    background-color: #dedede;\n    border: 0;\n    height: 1px;\n    margin-bottom: 1.7em;\n}\n\np {\n    margin: 0 0 1.7em;\n}\n\nul,\nol {\n    margin: 0 0 1.7em;\n}\n\nul {\n    list-style-type: disc;\n}\n\nol {\n    list-style-type: decimal;\n}\n\nul ul {\n    padding-left: 1em;\n}\n\nol ol {\n    padding-left: 1.3333em;\n}\n\nul ul,\nol ul {\n    list-style-type: circle;\n}\n\nul ol,\nol ol {\n    list-style-type: lower-alpha;\n}\n\nol ol ol {\n    list-style-type: decimal;\n}\n\nul ul,\nul ol,\nol ol,\nol ul {\n    font-size: inherit;\n    margin: 0.33333em 0;\n}\n\nul ul,\nol ul {\n    padding-left: 1em;\n}\n\nul ol,\nol ol {\n    padding-left: 1.44444em;\n}\n\ndl {\n    margin: 0 0 1.7em;\n}\n\ndt {\n    font-weight: 700;\n}\n\nli,\ndd {\n    margin-bottom: 0.19607843em;\n}\n\ndd {\n    margin-left: 0;\n}\n\ntable {\n    border-collapse: separate;\n    border-spacing: 0;\n    border-width: 0;\n    margin: 0 0 1.7em;\n    width: 100%;\n}\n\ncaption {\n    color: #333;\n    font-size: 30px;\n    font-size: 3rem;\n    font-weight: 700;\n    text-align: left;\n}\n\nth {\n    font-weight: 700;\n}\n\ntd {\n    font-weight: 400;\n}\n\ntr {\n    cursor: pointer;\n}\n\nth,\ntd {\n    padding: 10px;\n    line-height: 1.5;\n    border-bottom: 1px solid #ddd;\n    /*text-align: left;*/\n}\n\nthead {\n    color: #333;\n    font-size: 13px;\n    font-size: 1.3rem;\n    text-transform: uppercase;\n}\n\nthead th {\n    padding: 0.53846154em .5em;\n}\n\nfieldset {\n    border-width: 0;\n    clear: both;\n    margin: 0 0 3.4em;\n    padding: 0;\n}\n\nfieldset >:last-child {\n    margin-bottom: 0;\n}\n\nlegend {\n    border-bottom: 1px solid #dedede;\n    color: #333;\n    font-size: 13px;\n    font-size: 1.3rem;\n    font-weight: 700;\n    line-height: 1.7;\n    margin-bottom: 1.7em;\n    padding-bottom: 0.53846154em;\n    text-transform: uppercase;\n    width: 100%;\n}\n\nimg {\n    border: 0;\n    height: auto;\n    -ms-interpolation-mode: bicubic;\n    max-width: 100%;\n    vertical-align: middle;\n}\n\nfigure {\n    margin: 0;\n}\n\ndel {\n    opacity: 0.8;\n}\n\n::-webkit-input-placeholder {\n    color: #ababab;\n}\n\n:-moz-placeholder {\n    color: #ababab;\n}\n\n::-moz-placeholder {\n    color: #ababab;\n    opacity: 1;\n}\n\n:-ms-input-placeholder {\n    color: #ababab;\n}\n\n\n/**\n * Forms\n * -----------------------------------------------------------------------------\n */\n\nbutton,\ninput,\nselect,\ntextarea {\n    background-color: #fff;\n    border-radius: 0;\n    font-size: 13px;\n    font-size: 1.3rem;\n    line-height: 1.7;\n    margin: 0;\n    max-width: 100%;\n    vertical-align: baseline;\n}\n\nbutton,\ninput {\n    line-height: normal;\n}\n\nlabel {\n    color: #555;\n    display: inline-block;\n    font-weight: 700;\n}\n\ninput,\ntextarea {\n    background-image: -webkit-linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 0));\n    border: 1px solid #dedede;\n}\n\ninput:focus,\ntextarea:focus {\n    color: #333;\n    outline: 0;\n}\n\nbutton,\ninput[type=\"button\"],\ninput[type=\"reset\"],\ninput[type=\"submit\"],\n.button {\n    background-color: #555;\n    border: 0;\n    border-radius: 0;\n    color: #fff;\n    cursor: pointer;\n    display: inline-block;\n    font-family: \"Roboto\", sans-serif;\n    font-size: 11px;\n    font-size: 1.1rem;\n    font-weight: 400;\n    letter-spacing: 0.1em;\n    line-height: 1.90909091;\n    margin-bottom: 0.53846154em;\n    padding: 1.11538462em 1.53846154em;\n    text-align: center;\n    text-decoration: none;\n    text-transform: uppercase;\n}\n\nbutton:focus,\ninput[type=\"button\"]:focus,\ninput[type=\"reset\"]:focus,\ninput[type=\"submit\"]:focus,\n.button:focus {\n    background-color: #333;\n    color: #fff;\n    text-decoration: none;\n}\n\n.hover button:hover,\n.hover input[type=\"button\"]:hover,\n.hover input[type=\"reset\"]:hover,\n.hover input[type=\"submit\"]:hover,\n.hover .button:hover {\n    background-color: #333;\n    color: #fff;\n    text-decoration: none;\n}\n\n.button-alt {\n    background-color: #dedede;\n    color: #000;\n}\n\ninput[type=\"checkbox\"],\ninput[type=\"radio\"] {\n    padding: 0;\n}\n\ninput[type=\"search\"] {\n    -webkit-appearance: textfield;\n}\n\ninput[type=\"search\"]::-webkit-search-decoration {\n    -webkit-appearance: none;\n}\n\nbutton::-moz-focus-inner,\ninput::-moz-focus-inner {\n    border: 0;\n    padding: 0;\n}\n\ninput[type=\"email\"],\ninput[type=\"password\"],\ninput[type=\"search\"],\ninput[type=\"tel\"],\ninput[type=\"text\"],\ninput[type=\"url\"],\ntextarea {\n    color: #555;\n    padding: 0.84615385em 1.15384615em;\n    width: 100%;\n}\n\ninput[type=\"email\"]:focus,\ninput[type=\"password\"]:focus,\ninput[type=\"search\"]:focus,\ninput[type=\"tel\"]:focus,\ninput[type=\"text\"]:focus,\ninput[type=\"url\"]:focus,\ntextarea:focus {\n    border-color: #777;\n    color: #333;\n}\n\ninput[type=\"search\"] {\n    -moz-box-sizing: border-box;\n    box-sizing: border-box;\n}\n\ntextarea {\n    overflow: auto;\n    vertical-align: top;\n}\n\n\n/**\n * Accessibility\n * -----------------------------------------------------------------------------\n */\n\n.mejs-offscreen,\n.screen-reader-text,\n#wpstats {\n    clip: rect(1px, 1px, 1px, 1px);\n    height: 1px;\n    overflow: hidden;\n    position: absolute !important;\n    width: 1px;\n}\n\n.site .skip-link {\n    background-color: #f1f1f1;\n    box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.2);\n    color: #21759b;\n    display: block;\n    font-family: \"Roboto\", sans-serif;\n    font-size: 1em;\n    font-weight: 400;\n    outline: none;\n    padding: 1em 2em;\n    top: -9999em;\n    left: -9999em;\n    text-decoration: none;\n    text-transform: none;\n}\n\n.site .skip-link:focus {\n    clip: auto;\n    height: auto;\n    position: fixed !important;\n    top: 0.5em;\n    left: 0.5em;\n    width: auto;\n    z-index: 100000;\n}\n\n.logged-in .site .skip-link {\n    box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6);\n    font-size: 1em;\n    font-weight: 400;\n}\n\n.input-group {\n    display: table;\n    vertical-align: top;\n}\n.input-group input {\n\tborder-radius: 5px;\n}\n\n/**\n * Clearings\n * -----------------------------------------------------------------------------\n */\n\n.clearfix:before,\n.content-area:before,\n.site:before,\n.site-content:before,\n.clearfix:after,\n.content-area:after,\n.site:after,\n.site-content:after {\n    content: \" \";\n    display: table;\n}\n\n.clearfix:after,\n.content-area:after,\n.site:after,\n.site-content:after {\n    clear: both;\n}\n\n\n/**\n * Animations\n * -----------------------------------------------------------------------------\n */\n\n.fade-in {\n    -webkit-animation: fade-in 0.4s linear;\n    animation: fade-in 0.4s linear;\n    -webkit-backface-visibility: hidden;\n    backface-visibility: hidden;\n    -webkit-transform: translatez();\n    transform: translatez();\n}\n\n@-webkit-keyframes fade-in {\n    0% {\n        opacity: 0;\n    }\n    100% {\n        opacity: 1;\n    }\n}\n\n@keyframes fade-in {\n    0% {\n        opacity: 0;\n    }\n    100% {\n        opacity: 1;\n    }\n}\n\n\n/**\n * Header\n * -----------------------------------------------------------------------------\n */\n\n.site-header {\n    background-position: 50% 50%;\n    background-repeat: no-repeat;\n    background-size: cover;\n    position: relative;\n}\n\n.site-header:before {\n    background-color: #000;\n    content: \"\";\n    opacity: 0.5;\n    pointer-events: none;\n    position: absolute;\n    top: 0;\n    right: 0;\n    bottom: 0;\n    left: 0;\n}\n\n.site-branding {\n    max-width: 100%;\n    padding: 100px 45px;\n    position: relative;\n    text-align: center;\n}\n\n.site-description {\n    color: #fff;\n    font-family: \"Roboto\", sans-serif;\n    font-size: 13px;\n    font-size: 1.3rem;\n    font-weight: 400;\n    letter-spacing: 0.1em;\n    text-transform: uppercase;\n}\n\n.site-title {\n    color: #fff;\n    font-family: \"Roboto\", sans-serif;\n    font-size: 30px;\n    font-size: 3rem;\n    font-weight: 300;\n    letter-spacing: 0.1em;\n    line-height: 1;\n    margin: 20px 0;\n    text-transform: uppercase;\n    word-wrap: break-word;\n}\n\n.site-title a {\n    color: #fff;\n    text-decoration: none;\n}\n\n.site-title a:active,\n.site-title a:focus {\n    text-decoration: none;\n}\n\n.hover .site-title a:hover {\n    text-decoration: none;\n}\n\n@media screen and (min-width: 768px) {\n    .site-title {\n        font-size: 60px;\n        font-size: 6rem;\n    }\n}\n\n@media screen and (min-width: 1024px) {\n    .site-header {\n        display: -webkit-box;\n        display: -webkit-flex;\n        display: -moz-box;\n        display: -ms-flexbox;\n        display: flex;\n        position: fixed;\n        top: 0;\n        bottom: 0;\n        left: 0;\n        width: 50%;\n        -webkit-align-content: center;\n        align-content: center;\n        -webkit-align-items: center;\n        align-items: center;\n        -webkit-box-align: center;\n        -moz-box-align: center;\n        -webkit-box-pack: center;\n        -moz-box-pack: center;\n        -ms-flex-align: center;\n        -webkit-flex-flow: column no-wrap;\n        -ms-flex-flow: column no-wrap;\n        flex-flow: column no-wrap;\n        -ms-flex-line-pack: center;\n        -ms-flex-pack: center;\n        -webkit-justify-content: center;\n        justify-content: center;\n    }\n    .site-branding {\n        padding: 0 45px;\n    }\n    .home #lyricWrapper {\n        height: 240px;\n    }\n    .entry .entry-content .btn {\n        display: block;\n    }\n    .entry-content .content {\n        margin-bottom: 4em\n    }\n    .entry .form-table {\n\t    margin: 3.5em auto;\n\t    width: 100%;\n\t}\n}\n\n\n/**\n * Footer\n * -----------------------------------------------------------------------------\n */\n\n.site-footer {\n    background: #000;\n    color: #aaa;\n    font-family: \"Roboto\", sans-serif;\n    font-size: 13px;\n    font-size: 1.3rem;\n    padding: 30px 15px;\n    text-align: center;\n}\n\n.site-footer .social-navigation {\n    text-align: center;\n}\n\n\n/**\n * Content\n * -----------------------------------------------------------------------------\n */\n\n.hentry {\n    padding-bottom: 2em;\n}\n\n.hentry + .hentry,\n.infinite-loader + .hentry {\n    border-top: 1px solid #dedede;\n    padding-top: 2em;\n}\n\n.hentry.block-grid-item {\n    border-top-width: 0;\n    padding-bottom: 0;\n    padding-top: 0;\n}\n\n.entry-content {\n    word-wrap: break-word;\n}\n\n.entry-content .btn {\n    display: none;\n}\n\n.entry-content a {\n    text-decoration: underline;\n}\n\n.hover .entry-content a:hover {\n    opacity: 0.6;\n}\n\n.entry-content a.button {\n    text-decoration: none;\n    width: 200px;\n    border-radius: 5px;\n}\n\n.entry-content >:last-child {\n    margin-bottom: 0;\n}\n\n.entry-header {\n    display: -webkit-box;\n    display: -webkit-flex;\n    display: -moz-box;\n    display: -ms-flexbox;\n    display: flex;\n    margin-bottom: 1.6em;\n    -webkit-flex-flow: column nowrap;\n    -ms-flex-flow: column nowrap;\n    flex-flow: column nowrap;\n}\n\n.entry-header .breadcrumbs {\n    -webkit-box-ordinal-group: 2;\n    -moz-box-ordinal-group: 2;\n    -ms-flex-order: 1;\n    -webkit-order: 1;\n    order: 1;\n}\n\n.entry-header .entry-title {\n    -webkit-box-ordinal-group: 6;\n    -moz-box-ordinal-group: 6;\n    -ms-flex-order: 5;\n    -webkit-order: 5;\n    order: 5;\n}\n\n.entry-header .entry-subtitle {\n    -webkit-box-ordinal-group: 11;\n    -moz-box-ordinal-group: 11;\n    -ms-flex-order: 10;\n    -webkit-order: 10;\n    order: 10;\n}\n\n.entry-header .entry-meta {\n    -webkit-box-ordinal-group: 16;\n    -moz-box-ordinal-group: 16;\n    -ms-flex-order: 15;\n    -webkit-order: 15;\n    order: 15;\n}\n\n.entry-header .entry-meta {\n    font-family: \"Roboto\", sans-serif;\n    font-size: 11px;\n    font-size: 1.1rem;\n    letter-spacing: 0.1em;\n    margin-bottom: 0;\n    margin-top: 0.90909091em;\n    text-transform: uppercase;\n}\n\n.entry-header .entry-meta a {\n    color: #333;\n    text-decoration: none;\n}\n\n.entry-header .entry-meta .entry-comments-link:before {\n    content: \"\\2022\\00a0\";\n}\n\n.entry-header .entry-meta time.updated {\n    display: none;\n}\n\n.entry-media {\n    margin-bottom: 40px;\n}\n\n.entry-subtitle {\n    font-family: \"Roboto\", sans-serif;\n    font-size: 24px;\n    font-size: 2.4rem;\n    font-weight: 400;\n    line-height: 1.5;\n}\n\n.entry-terms {\n    font-family: \"Roboto\", sans-serif;\n    margin-bottom: 1.33333333em;\n}\n\n.entry-terms .term-group {\n    display: inline-block;\n    margin-right: 1.33333333em;\n}\n\n.entry-terms .term-group a {\n    color: #555;\n}\n\n.entry-terms .term-group:before {\n    color: #555;\n    font-size: 24px;\n    line-height: 1.0625em;\n    margin-right: 5px;\n}\n\n.entry-terms .term-group--category:before {\n    content: \"\\f21b\";\n}\n\n.entry-terms .term-group--post_tag:before {\n    content: \"\\f21c\";\n}\n\n\n@media screen and (min-width: 1024px) {\n    body.page .entry-footer,\n    body.single .entry-footer {\n        border-top: 1px solid #dedede;\n        margin-top: 1.33333333em;\n        padding-top: 1.33333333em;\n    }\n    body.page .entry-title,\n    body.single .entry-title {\n        font-size: 48px;\n        font-size: 4.8rem;\n    }\n    body.page .entry-title {\n        margin-bottom: 0;\n    }\n}\n\n\n/* Responsive */\n\n@media (min-width: 768px) {\n\n}\n\n.page-template-landing .hentry {\n    margin-bottom: 0;\n    max-width: 100%;\n    padding-bottom: 0;\n    text-align: center;\n}\n\n.page-template-landing .entry-content {\n    font-size: 20px;\n    font-size: 2rem;\n}\n\n@media screen and (min-width: 1024px) {\n    .page-template-landing .content-area {\n        display: -webkit-box;\n        display: -webkit-flex;\n        display: -moz-box;\n        display: -ms-flexbox;\n        display: flex;\n        flex-direction: row;\n        width: 100%;\n        justify-content: center;\n        -webkit-box-direction: normal;\n        -moz-box-direction: normal;\n        -webkit-box-orient: horizontal;\n        -moz-box-orient: horizontal;\n        -webkit-flex-direction: row;\n        -ms-flex-direction: row;\n        -webkit-flex-wrap: wrap;\n        -ms-flex-wrap: wrap;\n        flex-wrap: wrap;\n        -webkit-transition: all 2s linear;\n        -o-transition: all 2s linear;\n        transition: all 2s linear;\n    }\n    .page-template-landing .hentry {\n        display: -webkit-box;\n        display: -webkit-flex;\n        display: -moz-box;\n        display: -ms-flexbox;\n        display: flex;\n        max-width: 100%;\n        text-align: center;\n        width: 100%;\n        -webkit-align-content: center;\n        align-content: center;\n        -webkit-align-items: center;\n        align-items: center;\n        -webkit-box-align: center;\n        -moz-box-align: center;\n        -webkit-box-pack: center;\n        -moz-box-pack: center;\n        -ms-flex-align: center;\n        -webkit-flex-flow: column nowrap;\n        -ms-flex-flow: column nowrap;\n        flex-flow: column nowrap;\n        -ms-flex-line-pack: center;\n        -ms-flex-pack: center;\n        -webkit-justify-content: center;\n        justify-content: center;\n    }\n    .page-template-landing .entry-title {\n        font-size: 48px;\n        font-size: 4.8rem;\n    }\n    .page-template-landing .entry-content,\n    .page-template-landing .entry-title {\n        max-width: 100%;\n        text-align: center;\n        width: 100%;\n    }\n    .page-template-landing .comments-area {\n        max-width: 100%;\n        width: 100%;\n    }\n}\n\n\n/* Responsive Galleries */\n\n@media only screen and (min-width: 480px) {\n    .gallery-size-thumbnail .gallery-item {\n        max-width: 100%;\n    }\n}\n\n@media only screen and (min-width: 768px) {\n    .entry .entry-content .content {\n        margin-bottom: 2em\n    }\n}\n\n.site-content {\n    -webkit-transition: opacity 0.2s;\n    transition: opacity 0.2s;\n}\n\n.site-content.is-loading {\n    opacity: 0.05;\n    -webkit-transition: opacity 0.3s;\n    transition: opacity 0.3s;\n}\n\n.site-player .controls {\n    display: block;\n    margin-bottom: 40px;\n    padding-top: 85px;\n    position: relative;\n    z-index: 10;\n}\n\n.site-player .controls button {\n    background: none;\n    color: #9c9c9c;\n}\n\n.site-player button {\n    cursor: pointer;\n    display: block;\n    height: 32px;\n    margin: 0;\n    outline: none;\n    overflow: hidden;\n    padding: 0;\n    position: absolute;\n    top: 0;\n    left: 50%;\n    text-indent: 110%;\n    -webkit-transition: none;\n    transition: none;\n    white-space: nowrap;\n    width: 32px;\n}\n\n.site-player button:before {\n    display: inline-block;\n    font-family: \"themicons\";\n    font-size: 24px;\n    -moz-osx-font-smoothing: grayscale;\n    -webkit-font-smoothing: antialiased;\n    font-style: normal;\n    font-variant: normal;\n    font-weight: normal;\n    letter-spacing: normal;\n    line-height: 32px;\n    position: absolute;\n    top: 0;\n    right: 0;\n    bottom: 0;\n    left: 0;\n    text-align: center;\n    text-decoration: inherit;\n    text-indent: 0;\n    text-transform: none;\n    vertical-align: top;\n    speak: none;\n}\n\n.site-player button:active,\n.site-player button:focus {\n    background: none;\n    box-shadow: 0;\n    outline: 0;\n}\n\n.hover .site-player button:hover {\n    background: none;\n    box-shadow: 0;\n    outline: 0;\n}\n\n.site-player button.play-pause {\n    left: 32px;\n}\n\n.site-player button.play-pause:before {\n    content: \"\\f152\";\n}\n\n.site-player button.pause:before {\n    content: \"\\f151\";\n}\n\n.site-player button.next {\n    left: 64px;\n}\n\n.site-player button.next:before {\n    content: \"\\f155\";\n}\n\n.site-player button.previous {\n    left: 0;\n}\n\n.site-player button.previous:before {\n    content: \"\\f156\";\n}\n\n.site-player button.repeat,\n.site-player button.shuffle {\n    top: auto;\n    right: 0;\n    bottom: 0;\n    left: auto;\n    z-index: 2;\n}\n\n.site-player button.repeat.is-active,\n.site-player button.shuffle.is-active {\n    color: #fff;\n}\n\n.site-player button.repeat:before {\n    content: \"\\f15b\";\n}\n\n.site-player button.shuffle {\n    right: 41px;\n}\n\n.site-player button.shuffle:before {\n    content: \"\\f15c\";\n}\n\n.site-player button.volume-toggle {\n    display: block;\n    left: 0;\n}\n\n.site-player button.volume-toggle:before {\n    content: \"\\f159\";\n}\n\n.site-player button.volume-toggle.is-muted:before {\n    content: \"\\f158\";\n}\n\n.site-player .progress-bar {\n    background: rgba(255, 255, 255, 0.4);\n    border-radius: 2.5px;\n    cursor: pointer;\n    height: 5px;\n    position: absolute;\n    top: 40px;\n    right: 0;\n    left: 0;\n    z-index: 2;\n    display: flex;\n}\n\n.site-player .play-bar {\n    background: #fff;\n    height: 5px;\n    width: 0;\n}\n\n.site-player .volume-panel {\n    height: 35px;\n    position: absolute;\n    top: 0;\n    right: 0;\n    bottom: 0;\n    width: 165px;\n    color: #fff;\n}\n\n.site-player .volume-panel button {\n    color: #fff;\n}\n\n.site-player .volume-panel:hover .volume-toggle {\n    color: #fff;\n}\n\n.site-player .volume-panel:hover .volume-slider {\n    display: block;\n}\n\n.site-player .times {\n    position: absolute;\n    bottom: 0;\n    left: 0;\n}\n\n.site-player .volume-slider {\n    background-color: #000;\n    border-color: #000;\n    border-style: solid;\n    border-width: 20px 0;\n    display: none;\n    height: 150px;\n    margin-left: -25px;\n    position: absolute;\n    top: 32px;\n    left: 50%;\n    width: 50px;\n}\n\n.site-player .volume-slider:before {\n    background-color: #fff;\n    content: \"\";\n    cursor: pointer;\n    display: block;\n    margin-left: -3px;\n    position: absolute;\n    top: 0;\n    bottom: 0;\n    left: 50%;\n    width: 6px;\n}\n\n.site-player .volume-slider-handle {\n    background-color: #fff;\n    border-radius: 8px;\n    cursor: pointer;\n    display: block;\n    height: 16px;\n    margin: -8px 0 0 -8px;\n    position: absolute;\n    top: 0;\n    left: 50%;\n    width: 16px;\n}\n\n.site-player .playlist {\n    padding-bottom: 45px;\n    text-align: left;\n}\n\n.site-player .tracks-list {\n    border-color: #333;\n    border-style: solid;\n    border-width: 1px 0 0;\n    counter-reset: li;\n    display: table;\n    font-size: 13px;\n    font-size: 1.3rem;\n    font-weight: 400;\n    list-style-position: inside;\n    margin: 0;\n    padding: 0;\n    width: 100%;\n}\n\n.site-player .track {\n    border-color: #333;\n    border-style: solid;\n    border-width: 0 0 1px;\n    color: #aaa;\n    counter-increment: li;\n    cursor: pointer;\n    display: block;\n    margin: 0;\n    padding: 16px 0;\n    width: 100%;\n    /*\n\t\t&.is-error {\n\t\t\t&:before{\n\t\t\t\tdisplay: none;\n\t\t\t}\n\n\t\t\t.track-status {\n\t\t\t\tdisplay: table-cell;\n\n\t\t\t\t&:before {\n\t\t\t\t\tcontent: \"e\";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t*/\n}\n\n.site-player .track:before {\n    content: counter(li);\n    font-size: 13px;\n    font-size: 1.3rem;\n}\n\n.site-player .track .track-artist {\n    display: block;\n}\n\n.site-player .track .track-button {\n    border-color: rgba(255, 255, 255, 0.3);\n    color: rgba(255, 255, 255, 0.7);\n}\n\n.site-player .track .track-button:focus,\n.site-player .track .track-button:hover {\n    border-color: rgba(255, 255, 255, 0.5);\n    color: rgba(255, 255, 255, 0.9);\n    text-decoration: none;\n}\n\n.site-player .track .track-length {\n    width: 50px;\n}\n\n.site-player .track .track-status {\n    display: none;\n}\n\n.site-player .track .track-status:before {\n    content: \"\\f159\";\n    display: inline-block;\n    font-family: \"themicons\";\n    font-size: 20px;\n    -moz-osx-font-smoothing: grayscale;\n    -webkit-font-smoothing: antialiased;\n    font-style: normal;\n    font-variant: normal;\n    font-weight: normal;\n    letter-spacing: normal;\n    line-height: 0.75;\n    text-decoration: inherit;\n    text-transform: none;\n    vertical-align: top;\n    vertical-align: middle;\n    margin-left: -5px;\n    speak: none;\n}\n\n.site-player .track .track-title {\n    display: block;\n    font-size: 15px;\n    font-size: 1.5rem;\n}\n\n.site-player .track.is-current .track-artist,\n.site-player .track.is-current .track-title {\n    color: #fff;\n}\n\n.site-player .track-cell,\n.site-player .track:before {\n    display: block;\n    line-height: 1.3;\n}\n\n.site-player .track:before,\n.site-player .track-status,\n.site-player .track-remove {\n    max-width: 50px;\n    min-width: 50px;\n    padding-left: 0;\n    padding-right: 0;\n    text-align: center;\n    width: 50px;\n}\n\n.site-player .track:before,\n.site-player .track-actions:empty,\n.site-player .track-length {\n    display: none;\n}\n\n.site-player .track-actions {\n    display: block;\n    margin-top: 10px;\n    white-space: nowrap;\n}\n\n.site-player .track-details {\n    padding-left: 0;\n    padding-right: 0;\n    width: 100%;\n}\n\n.site-player .track-remove {\n    padding: 0;\n    text-align: right;\n}\n\n.site-player .track-remove button.remove {\n    background: transparent;\n    color: #555;\n    display: inline;\n    height: auto;\n    margin: 0;\n    position: relative;\n    top: auto;\n    right: auto;\n    left: auto;\n    text-align: right;\n    vertical-align: middle;\n}\n\n.site-player .track-remove button.remove:before {\n    content: \"\\f20c\";\n    font-size: 13px;\n    font-size: 1.3rem;\n    line-height: 1.3;\n}\n\n.site-player .track-remove button.remove:focus {\n    color: #aaa;\n}\n\n.hover .site-player .track-remove button.remove:hover {\n    color: #aaa;\n}\n\n@media screen and (min-width: 480px) {\n    .site-player .track {\n        border-width: 0;\n        display: table-row;\n        padding: 0;\n    }\n    .site-player .track-cell,\n    .site-player .track:before {\n        border-color: #333;\n        border-style: solid;\n        border-width: 0 0 1px;\n        display: table-cell;\n        line-height: 1.3;\n        padding: 16px 22px;\n        vertical-align: middle;\n    }\n    .site-player .track-actions,\n    .site-player .track-actions:empty {\n        display: table-cell;\n        margin: 0;\n        padding-right: 0;\n        text-align: right;\n    }\n}\n\n@media screen and (min-width: 768px) {\n    .site-player .track:before,\n    .site-player .track-actions,\n    .site-player .track.is-playing .track-status {\n        display: table-cell;\n    }\n    .site-player .track-details {\n        padding-left: 0;\n    }\n    .site-player .track-remove {\n        text-align: center;\n    }\n    .site-player .track-remove button.remove {\n        text-align: center;\n    }\n    .site-player .track.is-playing:before {\n        display: none;\n    }\n}\n\n.site-player {\n    font-weight: 400;\n}\n\n.site-player.is-loading {\n    display: none;\n}\n\n.site-player-panel {\n    background: #000;\n    border-width: 0;\n    clear: both;\n    color: #aaa;\n    display: -webkit-box;\n    display: -webkit-flex;\n    display: -moz-box;\n    display: -ms-flexbox;\n    display: flex;\n    flex-direction: column;\n    float: left;\n    font-size: 13px;\n    font-size: 1.3rem;\n    overflow: auto;\n    padding: 20px;\n    position: fixed;\n    top: 0;\n    right: 0;\n    bottom: 0;\n    text-align: left;\n    -webkit-transform: translate(100%);\n    transform: translate(100%);\n    z-index: 50;\n    -webkit-box-direction: normal;\n    -moz-box-direction: normal;\n    -webkit-box-orient: vertical;\n    -moz-box-orient: vertical;\n    -webkit-flex-direction: column;\n    -ms-flex-direction: column;\n    -webkit-overflow-scrolling: touch;\n}\n\n.site-current-track-details {\n    color: #fff;\n    display: none;\n    line-height: 20px;\n    padding: 0 110px;\n    position: fixed;\n    right: 50%;\n    bottom: 45px;\n    left: 0;\n    text-align: center;\n}\n\n.site-current-track-details .times {\n    font-size: 13px;\n    font-size: 1.3rem;\n    line-height: 1;\n    position: absolute;\n    right: 0;\n    bottom: -20px;\n    left: 0;\n}\n\n.site-play-pause-button,\n.site-player-toggle {\n    background: transparent;\n    color: #fff;\n    cursor: pointer;\n    display: block;\n    height: 48px;\n    line-height: 48px;\n    margin: 0;\n    outline: none;\n    overflow: hidden;\n    padding: 0;\n    position: absolute;\n    text-indent: 110%;\n    -webkit-transition: none;\n    transition: none;\n    white-space: nowrap;\n    width: 48px;\n    z-index: 20;\n}\n\n.site-play-pause-button:before,\n.site-player-toggle:before {\n    display: inline-block;\n    font-family: \"themicons\";\n    font-size: 24px;\n    -moz-osx-font-smoothing: grayscale;\n    -webkit-font-smoothing: antialiased;\n    font-style: normal;\n    font-variant: normal;\n    font-weight: normal;\n    letter-spacing: normal;\n    line-height: 48px;\n    position: absolute;\n    top: 0;\n    right: 0;\n    bottom: 0;\n    left: 0;\n    text-align: center;\n    text-decoration: inherit;\n    text-indent: 0;\n    text-transform: none;\n    vertical-align: top;\n    speak: none;\n}\n\n.site-play-pause-button:active,\n.site-player-toggle:active,\n.site-play-pause-button:focus,\n.site-player-toggle:focus {\n    background: none;\n    box-shadow: none;\n    opacity: 0.7;\n    outline: 0;\n}\n\n.hover .site-play-pause-button:hover,\n.hover .site-player-toggle:hover {\n    background: none;\n    box-shadow: none;\n    opacity: 0.7;\n    outline: 0;\n}\n\n.site-play-pause-button {\n    display: none;\n}\n\n.site-play-pause-button:before {\n    content: \"\\f152\";\n}\n\n.site-play-pause-button.pause:before {\n    content: \"\\f151\";\n}\n\n.site-player-toggle {\n    top: 4px;\n    right: 1px;\n    bottom: auto;\n    left: auto;\n}\n\n.site-player-toggle:before {\n    content: \"\\f153\";\n    font-size: 24px;\n}\n\n.site-player-toggle.is-open {\n    right: 85%;\n    left: auto;\n}\n\n.site-player-toggle.is-open:before {\n    content: \"\\f20c\";\n}\n\n.site-navigation-is-open .site-current-track-details,\n.site-navigation-is-open .site-play-pause-button,\n.site-navigation-is-open .site-player-toggle {\n    display: none;\n}\n\n.admin-bar .site-player-toggle,\n.admin-bar .site-player-toggle.is-open {\n    top: 50px;\n}\n\n@media screen and (max-width: 1023px) {\n    .site-player-is-open .site-navigation-toggle {\n        display: none;\n    }\n}\n\n@media screen and (min-width: 768px) {\n    .site-player-panel {\n        padding: 45px;\n    }\n}\n\n@media screen and (min-width: 783px) {\n    .site-player-toggle.is-open {\n        right: 70%;\n    }\n    .admin-bar .site-player-toggle,\n    .admin-bar .site-player-toggle.is-open {\n        top: 36px;\n    }\n}\n\n@media screen and (min-width: 1024px) {\n    .site-play-pause-button,\n    .site-player-toggle {\n        display: block;\n        position: fixed;\n        top: auto;\n        right: auto;\n        bottom: 31px;\n        left: auto;\n    }\n    .site-play-pause-button {\n        left: 31px;\n    }\n    .site-player-toggle,\n    .site-player-toggle.is-open,\n    .admin-bar .site-player-toggle,\n    .admin-bar .site-player-toggle.is-open {\n        top: auto;\n        right: calc(50% + 31px);\n    }\n}\n\n@media screen and (min-height: 500px) and (min-width: 1024px) {\n    .site-current-track-details {\n        display: block;\n    }\n}\n\n@-ms-viewport {\n    width: device-width;\n}\n\n@-moz-viewport {\n    width: device-width;\n}\n\n@-o-viewport {\n    width: device-width;\n}\n\n@-webkit-viewport {\n    width: device-width;\n}\n\n@viewport {\n    width: device-width;\n}\n\n\n/* rtl:ignore */\n\nbody.rtl {\n    direction: rtl;\n    unicode-bidi: embed;\n}\n\n#viewport-panel {\n    overflow: hidden;\n    position: relative;\n}\n\n.site {\n    position: relative;\n    left: 0;\n    -webkit-transition: left 0.19s;\n    transition: left 0.19s;\n}\n\n.site-content {\n    padding: 20px 15px;\n}\n\n.site-navigation-panel,\n.site-player-panel {\n    -webkit-transition: -webkit-transform 0.2s;\n    transition: -webkit-transform 0.2s;\n    transition: transform 0.2s;\n    transition: transform 0.2s, -webkit-transform 0.2s;\n    width: 85%;\n}\n\n.site-navigation-panel.is-animation-disabled,\n.site-player-panel.is-animation-disabled {\n    -webkit-transition: none;\n    transition: none;\n}\n\n.site-header .panel-body-footer {\n    display: none;\n}\n\n.admin-bar .site-navigation-panel,\n.admin-bar .site-player-panel {\n    top: 46px;\n}\n\n.site-navigation-is-open,\n.site-player-is-open {\n    overflow: hidden;\n}\n\n.site-navigation-is-open body,\n.site-player-is-open body {\n    overflow: hidden;\n}\n\n.site-navigation-is-open .site {\n    left: 85%;\n    -webkit-transition: left 0.21s;\n    transition: left 0.21s;\n}\n\n.site-navigation-is-open .site-navigation-panel {\n    -webkit-transform: translateX(0);\n    transform: translateX(0);\n}\n\n.site-player-is-open .site {\n    left: -85%;\n    -webkit-transition: left 0.21s;\n    transition: left 0.21s;\n}\n\n.site-player-is-open .site-player-panel {\n    -webkit-transform: translateX(0);\n    transform: translateX(0);\n}\n\n@media screen and (min-width: 560px) {\n    .site-content {\n        padding: 40px 80px;\n    }\n}\n\n@media screen and (min-width: 783px) {\n    .site-navigation-panel,\n    .site-player-panel {\n        width: 70%;\n    }\n    .admin-bar .site-navigation-panel,\n    .admin-bar .site-player-panel {\n        top: 32px;\n    }\n    .site-navigation-is-open .site {\n        left: 70%;\n    }\n    .site-player-is-open .site {\n        left: -70%;\n    }\n}\n\n@media screen and (min-width: 1024px) {\n    .site {\n        float: right;\n        min-height: 100vh;\n        padding-bottom: 20px;\n        padding-left: 60px;\n        padding-right: 60px;\n        padding-top: 60px;\n    }\n    .site,\n    .site-navigation-panel,\n    .site-player-panel {\n        width: 50%;\n    }\n    .site-content,\n    .admin-bar .site-content {\n        padding: 0;\n    }\n    .page-template-landing .site {\n        padding-bottom: 0;\n    }\n    .page-template-landing .hentry {\n        min-height: calc(100vh - 165px);\n    }\n    .site-header .panel-body-footer {\n        display: block;\n    }\n    .site-footer,\n    .site-footer .site-info {\n        display: none;\n    }\n    .admin-bar .site {\n        min-height: calc(100vh - 32px);\n    }\n    .admin-bar .site-header,\n    .admin-bar .site-navigation-panel,\n    .admin-bar .site-player-panel {\n        top: 32px;\n    }\n    .admin-bar.page-template-landing .hentry {\n        min-height: calc(100vh - 60px - 32px);\n    }\n    .site-navigation-is-open,\n    .site-navigation-is-open body {\n        overflow: auto;\n    }\n    .site-navigation-is-open .site,\n    .site-player-is-open .site {\n        left: 0;\n    }\n}\n\ninput[type=range] {\n    -webkit-appearance: none;\n    border: 1px solid #eee;\n    width: 130px;\n    position: absolute;\n    right: 0;\n    top: 14px;\n    height: 5px;\n    border-radius: 5px;\n}\n\ninput[type=range]::-webkit-slider-runnable-track {\n    width: auto;\n    height: 5px;\n    background: #ddd;\n    border: none;\n    border-radius: 5px;\n}\n\ninput[type=range]::-webkit-slider-thumb {\n    -webkit-appearance: none;\n    border: none;\n    height: 15px;\n    width: 15px;\n    border-radius: 50%;\n    background: #fff;\n    margin-top: -5px;\n}\n\ninput[type=range]:focus {\n    outline: none;\n}\n\ninput[type=range]:focus::-webkit-slider-runnable-track {\n    background: #ccc;\n}\n\n.form-table {\n    margin-bottom: 2em;\n    width: 100%;\n}\n\n.input-group {\n    width: 100%;\n}\n\n.table .is-playable:before {\n    content: \"\\f152\";\n    cursor: pointer;\n    display: inline-block;\n    font-family: \"themicons\";\n    font-size: 16px;\n    -moz-osx-font-smoothing: grayscale;\n    -webkit-font-smoothing: antialiased;\n    font-style: normal;\n}\n\n\n/* 必需 */\n\n.expand {\n    opacity: 0;\n    visibility: hidden;\n    margin-top: -8em;\n    transition: all .3s ease-out;\n}\n\n.insearch {\n    transition: all .3s ease-out;\n}\n\nul li {\n    list-style: none;\n}\n\n.pager li {\n    display: inline-block;\n    margin-left: 1em;\n}\n\n#lyricWrapper {\n    display: block;\n    height: 350px;\n    overflow: hidden;\n    position: relative;\n    top: -20px;\n    color: #fff;\n}\n\n#lyricContainer {\n    position: relative;\n    top: 100px;\n    width: 100%;\n    font-family: \"Microsoft YaHei\", Helvetica, Arial, sans-serif;\n    text-shadow: 1px 0 0 #000, -1px 0 0 #000, 0 1px 0 #000, 0 -1px 0 #000;\n}\n\n#lyricContainer p {\n    margin: 1.1em auto;\n    width: 100%;\n    font-size: 16px;\n    color: #5a5a5a;\n    text-align: center;\n    -webkit-transition: color .5s linear;\n    -moz-transition: color .5s linear;\n    -o-transition: color .5s linear;\n    transition: color .5s linear;\n}\n\n#lyricContainer .current-line {\n    color: #fff;\n    font-size: 18px;\n}\n\n.lyric-description {\n    position: relative;\n    top: 7em;\n}\n\n.play-point {\n    width: 12px;\n    height: 12px;\n    background-color: white;\n    border-radius: 100%;\n    box-shadow: 0 0 5px -1px;\n    margin-top: -4px;\n}\n\n\n/* IE10+ */\n\n@media all and (-ms-high-contrast: none),\n(-ms-high-contrast: active) {\n    #viewport-pane {\n        overflow: inherit;\n    }\n}\n"
  },
  {
    "path": "src/js/vplayer.js",
    "content": "var app = new Vue({\n  el: '#app',\n  data: {\n    audio: document.createElement('audio'),\n    storage: window.localStorage,\n    range: 0.5,\n    progress: 0,\n    playingId: '',\n    playingTitle: '',\n    playingArtist: '',\n    playingPic: '',\n    showCurrentTime: '0:00',\n    showDurationTime: '0:00',\n    currentIndex: 0,\n    search: '',\n    lyricText: '',\n    lyric: [],\n    songLists: [],\n    playingLists: [],\n    pageNumber: 1,\n    pages: 0,\n    offset: 30,\n    isNext: false,\n    lock: false,\n    listOpen: false,\n    isMuted: false,\n    isPlay: false,\n    isActive: false,\n    goSearch: false,\n    isMove: false,\n    isSearch: false,\n    isNull: true\n  },\n  created: function () {\n    this.firstOrCreate();\n  },\n  mounted: function () {\n    setInterval(this.setProgress, 500);\n    this.audio.addEventListener(\"timeupdate\", this.updateLyric);\n    this.audio.addEventListener(\"ended\", this.autoNextPlay);\n  },\n  methods: {\n    // 第一次创建（初始化）\n    firstOrCreate: function () {\n      this.playingLists = JSON.parse(this.storage.getItem('playerList'));\n      if (this.playingLists === null || this.playingLists.length === 0) {\n        this.playingLists = [];\n        var tmp = {\n          'id': 35283615,\n          'title': 'Dreams',\n          'picUrl': 'http://p3.music.126.net/tbnn45UGaEmkqXQlpD1iVQ==/3445869441930235.jpg',\n          'artists': 'Tobu'\n        };\n        this.playingLists.push(tmp);\n        this.storage.setItem('playerList', JSON.stringify(this.playingLists));\n      }\n      this.audio.volume = 0.5;\n      this.playingId = this.playingLists[0].id;\n      this.playingTitle = this.playingLists[0].title;\n      this.playingArtist = this.playingLists[0].artists;\n      this.playingPic = this.playingLists[0].picUrl;\n      this.$http.get('api/mp3url.php', {\n          params: {\n            'id': this.playingLists[0].id\n          }\n        })\n        .then(function (response) {\n          var mp3 = response.body.data[0];\n          this.audio.src = mp3.url;\n        }, function (error) {\n          //error callback\n          console.log(error);\n        });\n    },\n    // 去搜索\n    goSearch: function () {\n      this.goSearch = true;\n      document.querySelector('input[name=\"search\"]').focus();\n    },\n    // 自动播放\n    setAutoPlay: function () {\n      this.audio.autoplay = !this.audio.autoplay;\n      alert(this.audio.autoplay);\n    },\n    // 播放歌曲\n    setPlay: function (id) {\n      if (this.audio.paused) {\n        this.audio.play();\n        this.isPlay = true;\n        this.getSongLyric(id);\n      } else {\n        this.audio.pause();\n        this.isPlay = false;\n      }\n    },\n    // 调节音量\n    setVolume: function () {\n      this.audio.volume = this.range;\n      if (this.audio.volume === 0) {\n        this.isMuted = true;\n      } else {\n        this.isMuted = false;\n        this.audio.muted = false;\n      }\n    },\n    // 静音\n    setMuted: function () {\n      this.audio.muted = !this.audio.muted;\n      this.isMuted = this.audio.muted;\n    },\n    // 单曲循环\n    setLoop: function () {\n      this.audio.loop = !this.audio.loop;\n      this.isActive = !this.isActive;\n      console.log(this.audio.loop);\n    },\n    // 随机播放\n    setRandom: function () {\n      alert('功能暂未实现！');\n    },\n    // 打开/关闭歌单列表\n    isListOpen: function () {\n      this.listOpen = !this.listOpen;\n    },\n    // 播放进度条\n    setProgress: function () {\n      var MM, SS, CT, DT,\n        currentTime = this.audio.currentTime,\n        duration = this.audio.duration;\n      MM = parseInt(currentTime / 60);\n      SS = parseInt(currentTime % 60);\n      this.showCurrentTime = CT = MM + ':' + (SS < 10 ? '0' + SS : SS);\n\n      MM = parseInt(duration / 60);\n      SS = parseInt(duration % 60);\n      this.showDurationTime = DT = MM + ':' + (SS < 10 ? '0' + SS : SS);\n\n      var value = currentTime / duration * 100;\n      this.progress = value.toFixed(3);\n    },\n    // 搜索歌曲\n    formSubmit: function () {\n      this.goSearch = true;\n      if (this.search === '') {\n        return false;\n      }\n      this.$http.get('api/search.php', {\n          params: {\n            's': this.search\n          }\n        })\n        .then(function (response) {\n          this.songLists = response.body.result.songs;\n          this.isSearch = true;\n        }, function (error) {\n          // error callback\n          console.log(error);\n        });\n    },\n    // 播放歌曲\n    playMusic: function (id) {\n      var lyricContainer = document.querySelector('#lyricContainer');\n      lyricContainer.style.top = 110 + 'px';\n      this.getMp3Url(id);\n      this.$http.get('api/detail.php', {\n          params: {\n            'id': id\n          }\n        })\n        .then(function (response) {\n          var result = response.body.songs[0];\n          var id = result.id,\n            title = result.name,\n            picUrl = result.al.picUrl,\n            artist = [],\n            artists;\n          for (var i = 0; i < result.ar.length; i++) {\n            artist.push(result.ar[i].name)\n          }\n          artists = artist.join('/')\n          this.playingTitle = title;\n          this.playingArtist = artists;\n          this.playingPic = picUrl;\n          var tempData = {\n            'id': id,\n            'title': title,\n            'picUrl': picUrl,\n            'artists': artists\n          };\n          var obj = JSON.parse(this.storage.getItem('playerList'));\n          console.log(obj.length);\n          this.currentIndex = obj.length;\n          if (obj === null) {\n            this.playingLists.push(tempData);\n            this.storage.setItem('playerList', JSON.stringify(this.playingLists));\n          } else {\n            for (var i = 0; i < obj.length; i++) {\n              if (tempData.id == obj[i].id) {\n                this.lock = true;\n                break;\n              } else {\n                this.lock = false;\n              }\n            }\n          }\n          if (this.lock === false) {\n            this.playingLists = obj;\n            this.playingLists.push(tempData);\n            this.storage.setItem('playerList', JSON.stringify(this.playingLists));\n          } else {\n            alert('歌曲已经存在歌单中');\n            return false;\n          }\n        }, function (error) {\n          console.log(error);\n        });\n    },\n    // 播放历史歌单\n    playHistoryList: function (id, index) {\n      var lyricContainer = document.querySelector('#lyricContainer');\n      lyricContainer.style.top = 110 + 'px';\n      this.currentIndex = index;\n      this.getMp3Url(id);\n      var music = JSON.parse(this.storage.getItem('playerList'));\n      this.playingTitle = music[index].title;\n      this.playingArtist = music[index].artists;\n      this.playingPic = music[index].picUrl;\n    },\n    // 播放下一首\n    nextPlay: function () {\n      var next = JSON.parse(this.storage.getItem('playerList'));\n      if ((this.currentIndex + 1) == next.length) {\n        this.currentIndex = 0;\n      } else {\n        this.currentIndex = ++this.currentIndex;\n      }\n      this.playingTitle = next[this.currentIndex].title;\n      this.playingArtist = next[this.currentIndex].artists;\n      this.playingPic = next[this.currentIndex].picUrl;\n      this.getMp3Url(next[this.currentIndex].id);\n    },\n    // 播放上一首\n    prevPlay: function () {\n      var prev = JSON.parse(this.storage.getItem('playerList'));\n      if (this.currentIndex === 0) {\n        alert('这已经是第一首了');\n        return false;\n      } else {\n        this.currentIndex = --this.currentIndex;\n      }\n      this.playingTitle = prev[this.currentIndex].title;\n      this.playingArtist = prev[this.currentIndex].artists;\n      this.playingPic = prev[this.currentIndex].picUrl;\n      this.getMp3Url(prev[this.currentIndex].id);\n    },\n    // 列表循环播放\n    autoNextPlay: function () {\n      var lyricContainer = document.querySelector('#lyricContainer');\n      lyricContainer.style.top = 110 + 'px';\n      var obj = JSON.parse(this.storage.getItem('playerList'));\n      if ((this.currentIndex + 1) == obj.length) {\n        this.currentIndex = 0;\n      } else {\n        this.currentIndex = ++this.currentIndex;\n      }\n      if (!this.audio.loop) {\n        this.playingTitle = obj[this.currentIndex].title;\n        this.playingArtist = obj[this.currentIndex].artists;\n        this.playingPic = obj[this.currentIndex].picUrl;\n        this.getMp3Url(obj[this.currentIndex].id);\n      }\n    },\n    // 获取MP3链接\n    getMp3Url: function (id) {\n      this.$http.get('api/mp3url.php', {\n          params: {\n            'id': id\n          }\n        })\n        .then(function (response) {\n          var mp3 = response.body.data[0];\n          switch (mp3.code) {\n          case 404:\n            alert('因版权问题，歌曲已被下架！');\n            break;\n          case -110:\n            alert('此歌曲需要付费！无法播放！');\n            break;\n          default:\n            this.getSongLyric(id);\n            this.audio.src = mp3.url;\n            this.audio.play();\n            this.isPlay = true;\n          }\n        }, function (error) {\n          console.log(error);\n        });\n    },\n    // 获取歌词\n    getSongLyric: function (id) {\n      this.$http.get('api/lyric.php', {\n          params: {\n            'id': id\n          }\n        })\n        .then(function (response) {\n          var lrc = response.body;\n          if (lrc.nolyric === true) {\n            this.lyricText = '纯音乐 无歌词';\n            this.lyric = [];\n            return false;\n          } else if (lrc.uncollected === true) {\n            this.lyricText = '未收录歌词';\n            this.lyric = [];\n            return false;\n          }\n          if (!lrc.qfy && !lrc.sfy) {\n            this.lyricText = '';\n            this.parseLyric(lrc.lrc.lyric);\n          }\n        }, function (error) {\n          // error callback\n          console.log(error);\n        });\n    },\n    // 格式歌词\n    parseLyric: function (text) {\n      var lyric = text.split('\\n'), // 先按行分割\n        pattern = /\\[(\\d{2}):(\\d{2})\\.(\\d{2,3})]/g,\n        result = [],\n        offset = this.getOffset(text); // 调用歌词偏移\n      while (!pattern.test(lyric[0])) {\n        lyric = lyric.slice(1);\n      }\n      lyric[lyric.length - 1].length === 0 && lyric.pop();\n      lyric.forEach(function (v, i, a) {\n        var time = v.match(pattern),\n          value = v.replace(pattern, '');\n        time.forEach(function (v1, i1, a1) {\n          var t = v1.slice(1, -1).split(':');\n          result.push([parseInt(t[0], 10) * 60 + parseFloat(t[1]) + parseInt(offset) / 1000, value]);\n        });\n      });\n      result.sort(function (a, b) {\n        return a[0] - b[0];\n      });\n      this.lyric = result; // 赋值给data里面的lyric用于显示歌词\n    },\n    // 滚动歌词实现\n    updateLyric: function () {\n      if (this.lyric.length === 0 || '') return false;\n      var lyricContainer = document.querySelector('#lyricContainer');\n      for (var i = 0, l = this.lyric.length; i < l; i++) {\n        if (this.audio.currentTime > this.lyric[i][0] - 0.50) {\n          var line = document.getElementById('line-' + i),\n            prevLine = document.getElementById('line-' + (i > 0 ? i - 1 : i));\n          prevLine.className = '';\n          line.className = 'current-line';\n          lyricContainer.style.top = 110 - line.offsetTop + 'px';\n        }\n      }\n    },\n    // 歌词偏移\n    getOffset: function (text) {\n      var offset = 0;\n      try {\n        var offsetPattern = /\\[offset:\\-?\\+?\\d+\\]/g,\n          offset_line = text.match(offsetPattern)[0],\n          offset_str = offset_line.split(':')[1];\n        offset = parseInt(offset_str);\n      } catch (err) {\n        offset = 0;\n      }\n      return offset;\n    },\n    // 上一页\n    prevPage: function () {\n      this.pages = this.pages - this.offset;\n      this.pageNumber--;\n      this.$http.get('api/pages.php', {\n          params: {\n            's': this.search,\n            'p': this.pages\n          }\n        })\n        .then(function (response) {\n          this.songLists = response.body.result.songs;\n        }, function (error) {\n          // error callback\n          console.log(error);\n        });\n    },\n    // 下一页\n    nextPage: function () {\n      pn = this.pageNumber++;\n      this.pages = pn * this.offset;\n      this.$http.get('api/pages.php', {\n          params: {\n            's': this.search,\n            'p': this.pages\n          }\n        })\n        .then(function (response) {\n          this.songLists = response.body.result.songs;\n        }, function (error) {\n          // error callback\n          console.log(error);\n        });\n    },\n    // 删除历史歌单歌曲\n    removeList: function (index) {\n      var lists = JSON.parse(this.storage.getItem('playerList')),\n        changeList = lists.slice(0, index).concat(lists.slice(parseInt(index, 10) + 1));\n      this.storage.setItem('playerList', JSON.stringify(changeList));\n      var tempList = JSON.parse(this.storage.getItem('playerList'));\n      this.playingLists = tempList;\n      console.log('歌曲已从播放历史歌单中删除!');\n    },\n    // 点击进度条快进\n    clickProgress: function (e) {\n      // console.log(e);\n      var percent = e.offsetX / e.target.offsetWidth,\n        value = percent * this.audio.duration;\n      this.audio.currentTime = value.toFixed(3);\n    }\n  }\n});\n"
  }
]