public static function decode($base32)
    {
        $bytes = [];
        $base32Len = \strlen($base32);
        $base32LookupLen = \count(self::$base32Lookup);

        for ($i = $base32Len * 5 / 8 - 1; $i >= 0; --$i) {
            $bytes[] = 0;
        }

        for ($i = 0, $index = 0, $offset = 0; $i < $base32Len; $i++) {
            $lookup = \ord($base32[$i]) - \ord('0');

            /* Skip chars outside the lookup table */
            if ($lookup < 0 || $lookup >= $base32LookupLen) {
                continue;
            }

            $digit = self::$base32Lookup[$lookup];

            /* If this digit is not in the table, ignore it */
            if ($digit === 0xFF) {
                continue;
            }

            if ($index <= 3) {
                $index = ($index + 5) % 8;
                if ($index === 0) {
                    $bytes[$offset] |= $digit;
                    $offset++;
                    if ($offset >= \count($bytes)) {
                        break;
                    }
                } else {
                    $bytes[$offset] |= $digit << (8 - $index);
                }
            } else {
                $index = ($index + 5) % 8;
                $bytes[$offset] |= ($digit >> $index);
                $offset++;
                if ($offset >= \count($bytes)) {
                    break;
                }
                $bytes[$offset] |= $digit << (8 - $index);
            }
        }

        $bites = '';
        foreach ($bytes as $byte) {
            $bites .= \chr($byte);
        }

        return $bites;
    }