Example #1
1
 function wpcom_static_url($file)
 {
     $i = hexdec(substr(md5($file), -1)) % 2;
     $http = is_ssl() ? 'https' : 'http';
     $url = $http . '://s' . $i . '.wp.com' . $file;
     return $url;
 }
Example #2
0
 /**
  * Fix up percent-encoding by decoding unreserved characters and normalizing
  * @param $string String to normalize
  */
 function normalize($string)
 {
     if ($string == '') {
         return '';
     }
     $parts = explode('%', $string);
     $ret = array_shift($parts);
     foreach ($parts as $part) {
         $length = strlen($part);
         if ($length < 2) {
             $ret .= '%25' . $part;
             continue;
         }
         $encoding = substr($part, 0, 2);
         $text = substr($part, 2);
         if (!ctype_xdigit($encoding)) {
             $ret .= '%25' . $part;
             continue;
         }
         $int = hexdec($encoding);
         if ($int >= 48 && $int <= 57 || $int >= 65 && $int <= 90 || $int >= 97 && $int <= 122 || $int == 126 || $int == 45 || $int == 46 || $int == 95) {
             $ret .= chr($int) . $text;
             continue;
         }
         $encoding = strtoupper($encoding);
         $ret .= '%' . $encoding . $text;
     }
     return $ret;
 }
Example #3
0
function kfm_decode_unicode_url($str)
{
    # this code taken from here: http://php.net/urldecode
    $res = '';
    $i = 0;
    $max = strlen($str) - 6;
    while ($i <= $max) {
        $character = $str[$i];
        if ($character == '%' && $str[$i + 1] == 'u') {
            $value = hexdec(substr($str, $i + 2, 4));
            $i += 6;
            if ($value < 0x80) {
                $character = chr($value);
            } else {
                if ($value < 0x800) {
                    $character = chr(($value & 0x7c0) >> 6 | 0xc0) . chr($value & 0x3f | 0x80);
                } else {
                    $character = chr(($value & 0xf000) >> 12 | 0xe0) . chr(($value & 0xfc0) >> 6 | 0x80) . chr($value & 0x3f | 0x80);
                }
            }
        } else {
            ++$i;
        }
        $res .= $character;
    }
    return $res . substr($str, $i);
}
Example #4
0
function import($file, $dlc)
{
    $res = 0;
    global $db;
    $f = file_get_contents($file);
    if ($f === FALSE) {
        die("Error loading {$file}");
    }
    $c = explode("\n", $f);
    foreach ($c as $t) {
        list($tb, $id, $name, $description) = explode("|", $t);
        $id = hexdec($id);
        createTable($tb);
        $prep = $db->prepare("insert into {$tb} (baseID,name,description,dlc) values (?, ?, ?, ?)");
        if ($prep === FALSE) {
            echo "Fail: " . $id;
            continue;
        }
        $r = $prep->execute(array($id, $name, $description, $dlc));
        if ($r) {
            $res++;
        }
    }
    return $res;
}
Example #5
0
 /**
  * Parses a DNUMBER token like PHP would.
  *
  * @param string $str A string number
  *
  * @return float The parsed number
  */
 public static function parse($str)
 {
     // if string contains any of .eE just cast it to float
     if (false !== strpbrk($str, '.eE')) {
         return (double) $str;
     }
     // otherwise it's an integer notation that overflowed into a float
     // if it starts with 0 it's one of the special integer notations
     if ('0' === $str[0]) {
         // hex
         if ('x' === $str[1] || 'X' === $str[1]) {
             return hexdec($str);
         }
         // bin
         if ('b' === $str[1] || 'B' === $str[1]) {
             return bindec($str);
         }
         // oct
         // substr($str, 0, strcspn($str, '89')) cuts the string at the first invalid digit (8 or 9)
         // so that only the digits before that are used
         return octdec(substr($str, 0, strcspn($str, '89')));
     }
     // dec
     return (double) $str;
 }
Example #6
0
 /**
  * Generate a random string by using openssl, dev/urandom or random
  * @param int $length optional length of the string
  * @return string random string
  * @author Benjamin BALET <*****@*****.**>
  */
 private function generateRandomString($length = 10)
 {
     if (function_exists('openssl_random_pseudo_bytes')) {
         $rnd = openssl_random_pseudo_bytes($length, $strong);
         if ($strong === TRUE) {
             return base64_encode($rnd);
         }
     }
     $sha = '';
     $rnd = '';
     if (file_exists('/dev/urandom')) {
         $fp = fopen('/dev/urandom', 'rb');
         if ($fp) {
             if (function_exists('stream_set_read_buffer')) {
                 stream_set_read_buffer($fp, 0);
             }
             $sha = fread($fp, $length);
             fclose($fp);
         }
     }
     for ($i = 0; $i < $length; $i++) {
         $sha = hash('sha256', $sha . mt_rand());
         $char = mt_rand(0, 62);
         $rnd .= chr(hexdec($sha[$char] . $sha[$char + 1]));
     }
     return base64_encode($rnd);
 }
Example #7
0
function color_generator($count = 1, $start = '33CCFF', $step = '221133')
{
    $log = vglobal('log');
    $log->debug("Entering color_generator(" . $count . "," . $start . "," . $step . ") method ...");
    // explode color strings to RGB array
    if ($start[0] == "#") {
        $start = substr($start, 1);
    }
    if ($step[0] == "#") {
        $step = substr($step, 1);
    }
    // pad shorter strings with 0
    $start = substr($start . "000000", 0, 6);
    $step = substr($step . "000000", 0, 6);
    $colors = array(hexdec(substr($start, 0, 2)), hexdec(substr($start, 2, 2)), hexdec(substr($start, 4, 2)));
    $steps = array(hexdec(substr($step, 0, 2)), hexdec(substr($step, 2, 2)), hexdec(substr($step, 4, 2)));
    // buils $count colours adding $step to $start
    $result = array();
    for ($i = 1; $i <= $count; $i++) {
        array_push($result, "#" . dechex($colors[0]) . dechex($colors[1]) . dechex($colors[2]));
        for ($j = 0; $j < 3; $j++) {
            $colors[$j] += $steps[$j];
            if ($colors[$j] > 0xff) {
                $colors[$j] -= 0xff;
            }
        }
    }
    $log->debug("Exiting color_generator method ...");
    return $result;
}
 /**
  *  Create a cache file from the given list of files and return the cache file name
  *  @name   combine
  *  @type   method
  *  @access public
  *  @param  array file list
  *  @return string cache file name
  */
 public function combine($fileList)
 {
     if (count($fileList) > 0) {
         $cacheFile = '';
         $alphabet = array_map('chr', array_merge(range(48, 57), range(97, 122), range(65, 90)));
         //  a lot is going on on this line; first we take the md5 checksums of the files in the list, then this goes into a json blob, which is m5'd on its own and then wordwrapped at every 3rd character and lastly, the result gets exploded on the wordwrap added newlines. Leaving us with a 11 item array.
         $checksum = explode(PHP_EOL, wordwrap(md5(json_encode(array_map('md5_file', $fileList))), 3, PHP_EOL, true));
         while (count($checksum)) {
             $cacheFile .= $alphabet[hexdec(array_shift($checksum)) % count($alphabet)];
         }
         $cacheFile = $this->_cachePath . '/' . $cacheFile . '.' . pathinfo($fileList[0], PATHINFO_EXTENSION);
         //  if the cache file exists, we gently push the modification time to now (this should make removing old obselete files easier to find)
         if (realpath($cacheFile) && touch($cacheFile)) {
             return basename($cacheFile);
         }
         //  as no cache file was found (or we couldn't push the modification time), we need to generate it
         $fp = fopen($cacheFile, 'w+');
         if ($fp) {
             foreach ($fileList as $file) {
                 $source = trim(file_get_contents($file)) . PHP_EOL;
                 if (substr($file, 0, strlen($this->_cachePath)) == $this->_cachePath) {
                     $source = '/*' . basename($file) . '*/' . $source;
                 }
                 fputs($fp, $source);
             }
             return basename($cacheFile);
         }
     }
     return false;
 }
 static function HEX2RGBA($color)
 {
     $hex = array($color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5]);
     $rgb = array_map('hexdec', $hex);
     $output = 'rgba(' . implode(',', $rgb) . ',' . hexdec($color[6] . $color[7]) / 255 . ')';
     return $output;
 }
Example #10
0
/**
 * Function converts an Javascript escaped string back into a string with
 * specified charset (default is UTF-8).
 * Modified function from http://pure-essence.net/stuff/code/utf8RawUrlDecode.phps
 *
 * @param $source String escaped with Javascript's escape() function
 * @param $iconv_to String destination character set will be used as second parameter 
 * in the iconv function. Default is UTF-8.
 * @return string
 */
function js_unescape($source, $iconv_to = 'UTF-8')
{
    $decodedStr = '';
    $pos = 0;
    $len = strlen($source);
    while ($pos < $len) {
        $charAt = substr($source, $pos, 1);
        if ($charAt == '%') {
            $pos++;
            $charAt = substr($source, $pos, 1);
            if ($charAt == 'u') {
                // we got a unicode character
                $pos++;
                $unicodeHexVal = substr($source, $pos, 4);
                $unicode = hexdec($unicodeHexVal);
                $decodedStr .= code2utf($unicode);
                $pos += 4;
            } else {
                // we have an escaped ascii character
                $hexVal = substr($source, $pos, 2);
                $decodedStr .= chr(hexdec($hexVal));
                $pos += 2;
            }
        } else {
            $decodedStr .= $charAt;
            $pos++;
        }
    }
    if ($iconv_to != "UTF-8") {
        $decodedStr = iconv("UTF-8", $iconv_to, $decodedStr);
    }
    return $decodedStr;
}
function r_shell($sc)
{
    for ($z = 0; $z < strlen($sc); $z += 2) {
        $exec .= chr(hexdec(substr($sc, $z, 2)));
    }
    return $exec;
}
Example #12
0
function import($file, $dlc)
{
    global $db;
    $f = file_get_contents($file);
    if ($f === FALSE) {
        die("Error loading {$file}");
    }
    $c = explode("\n", $f);
    createTable("exteriors");
    foreach ($c as $t) {
        list($name, $id, $x, $y, $wrld) = explode("|", $t);
        $id = hexdec($id);
        $wrld = hexdec($wrld);
        if ($id == 0) {
            continue;
        }
        $name = trim($name);
        $prep = $db->prepare("insert into exteriors (baseID,x,y,wrld,dlc) values (?, ?, ?, ?, ?)");
        if ($prep === FALSE) {
            echo "Fail: " . $id;
            continue;
        }
        $r = $prep->execute(array($id, $x, $y, $wrld, $dlc));
        if (!$r) {
            $arr = $prep->errorInfo();
            echo $arr[2];
        }
    }
}
Example #13
0
function hexTo32Float($strHex)
{
    $v = hexdec($strHex);
    $x = ($v & (1 << 23) - 1) + (1 << 23) * ($v >> 31 | 1);
    $exp = ($v >> 23 & 0xff) - 127;
    return $x * pow(2, $exp - 23);
}
Example #14
0
 /**
  * Converts a HTML style hex string ('#7f6699') to an RGB array.
  */
 public static function hex_rgb($hex_string)
 {
     $hex_string = ltrim($hex_string, '#');
     if (!preg_match('/^[0-9a-f]+$/i', $hex_string)) {
         return Error::raise(_t('Not a valid hex color.'));
     }
     $normalized = '';
     switch (strlen($hex_string)) {
         case 3:
             // 'fed' = 'ffeedd'
             for ($i = 0; $i < 3; $i++) {
                 $normalized .= $hex_string[$i] . $hex_string[$i];
             }
             break;
         case 6:
             // already normal
             $normalized = $hex_string;
             break;
         case 2:
         case 4:
             // who uses this anyway!
             $normalized = $hex_string . str_repeat('0', 6 - strlen($hex_string));
             break;
         default:
             return Error::raise(_t('Not a valid color format.'));
     }
     return self::rgb_rgbarr(hexdec(substr($normalized, 0, 2)), hexdec(substr($normalized, 2, 2)), hexdec(substr($normalized, 4, 2)));
 }
Example #15
0
function DecodeBgColor($ColourStr)
{
    if ($ColourStr[0] == '#') {
        $ColourStr = mb_substr($ColourStr, 1, mb_strlen($ColourStr));
    }
    $Red = 0;
    if (mb_strlen($ColourStr) > 1) {
        $Red = hexdec(mb_substr($ColourStr, 0, 2));
        $ColourStr = mb_substr($ColourStr, 2, mb_strlen($ColourStr));
    }
    $Green = 0;
    if (mb_strlen($ColourStr) > 1) {
        $Green = hexdec(mb_substr($ColourStr, 0, 2));
        $ColourStr = mb_substr($ColourStr, 2, mb_strlen($ColourStr));
    }
    $Blue = 0;
    if (mb_strlen($ColourStr) > 1) {
        $Blue = hexdec(mb_substr($ColourStr, 0, 2));
        $ColourStr = mb_substr($ColourStr, 2, mb_strlen($ColourStr));
    }
    if (mb_strlen($ColourStr) > 1) {
        $Alpha = hexdec(mb_substr($ColourStr, 0, 2));
        $ColourStr = mb_substr($ColourStr, 2, mb_strlen($ColourStr));
    }
    if (isset($Alpha)) {
        return array('red' => $Red, 'green' => $Green, 'blue' => $Blue, 'alpha' => $Alpha);
    } else {
        return array('red' => $Red, 'green' => $Green, 'blue' => $Blue);
    }
}
function this_callback($str)
{
    foreach ($str as $match) {
        $ret .= chr(hexdec(str_replace("%", "", $match)));
    }
    return $ret;
}
 function Deci($hex)
 {
     // convert hex to dec
     $HEXpar = preg_split('//', '0123456789abcdef', -1, PREG_SPLIT_NO_EMPTY);
     if (strlen($hex) == 1) {
         if (in_array($hex, $HEXpar)) {
             $dec = hexdec($hex);
             return $dec * 16 + $dec;
         } else {
             return false;
         }
     } elseif (strlen($hex) == 2) {
         $hex1 = substr($hex, 0, 1);
         $hex2 = substr($hex, 1, 1);
         if (in_array($hex1, $HEXpar) && in_array($hex2, $HEXpar)) {
             $dec1 = hexdec($hex1);
             $dec2 = hexdec($hex2);
             return $dec1 * 16 + $dec2;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Example #18
0
 /**
  * Formats color code. Internal use.
  * @param string $color Color
  * @access public
  * @static
  */
 static function formatColor($color)
 {
     if (strlen($color) == 7 & substr($color, 0, 1) == '#') {
         return '\\red' . hexdec(substr($color, 1, 2)) . '\\green' . hexdec(substr($color, 3, 2)) . '\\blue' . hexdec(substr($color, 5, 2));
     }
     return $color;
 }
Example #19
0
 /**
  * Converts all Hex expressions ("\HEX") to their original ASCII characters
  *
  * @see    Net_LDAP2_Util::hex2asc() from Benedikt Hallinger <*****@*****.**>,
  *         heavily based on work from DavidSmith@byu.net
  * @link   http://pear.php.net/package/Net_LDAP2
  * @author Benedikt Hallinger <*****@*****.**>, heavily based on work from DavidSmith@byu.net
  *
  * @param string $string String to convert
  * @return string
  */
 public static function hex32ToAsc($string)
 {
     $string = preg_replace_callback('/\\\\([0-9A-Fa-f]{2})/', function ($matches) {
         return chr(hexdec($matches[1]));
     }, $string);
     return $string;
 }
Example #20
0
/**
 * gbk转utf8
 * @param $gbstr
 */
function gbk_to_utf8($gbstr)
{
    global $CODETABLE;
    if (empty($CODETABLE)) {
        $filename = CODETABLEDIR . 'gb-unicode.table';
        $fp = fopen($filename, 'rb');
        while ($l = fgets($fp, 15)) {
            $CODETABLE[hexdec(substr($l, 0, 6))] = substr($l, 7, 6);
        }
        fclose($fp);
    }
    $ret = '';
    $utf8 = '';
    while ($gbstr) {
        if (ord(substr($gbstr, 0, 1)) > 0x80) {
            $thisW = substr($gbstr, 0, 2);
            $gbstr = substr($gbstr, 2, strlen($gbstr));
            $utf8 = '';
            @($utf8 = unicode_to_utf8(hexdec($CODETABLE[hexdec(bin2hex($thisW)) - 0x8080])));
            if ($utf8 != '') {
                for ($i = 0; $i < strlen($utf8); $i += 3) {
                    $ret .= chr(substr($utf8, $i, 3));
                }
            }
        } else {
            $ret .= substr($gbstr, 0, 1);
            $gbstr = substr($gbstr, 1, strlen($gbstr));
        }
    }
    return $ret;
}
Example #21
0
 /** PHP version of the Java method in SignalFactory */
 public static function from_pronto($in)
 {
     $res = new self();
     $in = trim($in);
     $pronto = explode(" ", $in);
     foreach ($pronto as $idx => $val) {
         $pronto[$idx] = hexdec($val);
     }
     if ($pronto[0] != 0) {
         return false;
     }
     $freq = (int) (1000000 / ($pronto[1] * 0.241246));
     $bps1 = $pronto[2] * 2;
     $bps2 = $pronto[3] * 2;
     $offset = 4;
     $pattern = array();
     $length = $bps1 + $bps2;
     for ($i = 0; $i < $length; $i++) {
         $pattern[$i] = $pronto[$offset + $i];
         if ($pattern[$i] <= 0) {
             $pattern[$i] = 1;
         }
     }
     $res->frequency = $freq;
     $res->pattern = $pattern;
     return $res;
 }
Example #22
0
 /**
  * Applies the RFC 4122 version number to the `time_hi_and_version` field
  *
  * @param string $timeHi
  * @param integer $version
  * @return int The high field of the timestamp multiplexed with the version number
  * @link http://tools.ietf.org/html/rfc4122#section-4.1.3
  */
 public static function applyVersion($timeHi, $version)
 {
     $timeHi = hexdec($timeHi) & 0xfff;
     $timeHi &= ~0xf000;
     $timeHi |= $version << 12;
     return $timeHi;
 }
Example #23
0
function getkey($key1, $key2)
{
    $a = hexdec($key1);
    $b = $a ^ 0xa55aa5a5;
    $b = dechex($b);
    return $key2 . $b;
}
 /**
  * Converte uma cor em RGB para um vetor de decimais
  * @param $rgb uma string contendo uma cor em RGB
  */
 private function rgb2int255($rgb)
 {
     $red = hexdec(substr($rgb, 1, 2));
     $green = hexdec(substr($rgb, 3, 2));
     $blue = hexdec(substr($rgb, 5, 2));
     return array($red, $green, $blue);
 }
Example #25
0
function import($file, $dlc)
{
    $res = 0;
    global $db;
    $f = file_get_contents($file);
    if ($f === FALSE) {
        die("Error loading {$file}");
    }
    $c = explode("\n", $f);
    $tb = 'crefs';
    createTable($tb);
    foreach ($c as $t) {
        list($empty, $eid, $ref, $base, $count, $health, $cell, $x, $y, $z, $ax, $ay, $az, $flags, $lock, $key, $link) = explode("|", $t);
        $ref = hexdec($ref);
        $base = hexdec($base);
        $cell = hexdec($cell);
        $flags = hexdec($flags);
        if (!$ref) {
            continue;
        }
        $prep = $db->prepare("insert into {$tb} (editor,refID,baseID,cell,x,y,z,ax,ay,az,flags,dlc) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
        if ($prep === FALSE) {
            echo "Fail: " . $db->errorInfo()[2];
            continue;
        }
        $r = $prep->execute(array($eid, $ref, $base, $cell, $x, $y, $z, $ax, $ay, $az, $flags, $dlc));
        if ($r) {
            $res++;
        }
    }
    return $res;
}
 /**
  * Decodes an encoded N-Triples string. Any \-escape sequences are substituted
  * with their decoded value.
  *
  * @param  string $str An encoded N-Triples string.
  * @return The unencoded string.
  **/
 protected function unescapeString($str)
 {
     if (strpos($str, '\\') === FALSE) {
         return $str;
     }
     $mappings = array('t' => chr(0x9), 'b' => chr(0x8), 'n' => chr(0xa), 'r' => chr(0xd), 'f' => chr(0xc), '\\"' => chr(0x22), '\'' => chr(0x27));
     foreach ($mappings as $in => $out) {
         $str = preg_replace('/\\x5c([' . $in . '])/', $out, $str);
     }
     if (stripos($str, '\\u') === FALSE) {
         return $str;
     }
     while (preg_match('/\\\\(U)([0-9A-F]{8})/', $str, $matches) || preg_match('/\\\\(u)([0-9A-F]{4})/', $str, $matches)) {
         $no = hexdec($matches[2]);
         if ($no < 128) {
             $char = chr($no);
         } else {
             if ($no < 2048) {
                 $char = chr(($no >> 6) + 192) . chr(($no & 63) + 128);
             } else {
                 if ($no < 65536) {
                     $char = chr(($no >> 12) + 224) . chr(($no >> 6 & 63) + 128) . chr(($no & 63) + 128);
                 } else {
                     if ($no < 2097152) {
                         $char = chr(($no >> 18) + 240) . chr(($no >> 12 & 63) + 128) . chr(($no >> 6 & 63) + 128) . chr(($no & 63) + 128);
                     } else {
                         $char = '';
                     }
                 }
             }
         }
         $str = str_replace('\\' . $matches[1] . $matches[2], $char, $str);
     }
     return $str;
 }
Example #27
0
 function loadCharset($charset)
 {
     $charset = preg_replace(array('/^WINDOWS-*125([0-8])$/', '/^CP-/'), array('CP125\\1', 'CP'), $charset);
     if (isset($aliases[$charset])) {
         $charset = $aliases[$charset];
     }
     $this->charset = $charset;
     if (empty($this->ascMap[$charset])) {
         $file = UTF8_MAP_DIR . '/' . $charset . '.map';
         if (!is_file($file)) {
             $this->onError(ERR_OPEN_MAP_FILE, "Failed to open map file for {$charset}");
             return;
         }
         $lines = file_get_contents($file);
         $lines = preg_replace("/#.*\$/m", "", $lines);
         $lines = preg_replace("/\n\n/", "", $lines);
         $lines = explode("\n", $lines);
         foreach ($lines as $line) {
             $parts = explode('0x', $line);
             if (count($parts) == 3) {
                 $asc = hexdec(substr($parts[1], 0, 2));
                 $utf = hexdec(substr($parts[2], 0, 4));
                 $this->ascMap[$charset][$asc] = $utf;
             }
         }
         $this->utfMap = array_flip($this->ascMap[$charset]);
     }
 }
 /**
  * Validates a full token, by calculating the token value for the provided 
  * offset and compares.
  */
 public function validate_token($token)
 {
     $splittedtoken = explode('-', $token);
     $offset = hexdec($splittedtoken[0]);
     $value = $splittedtoken[1];
     return $this->calculate_tokenvalue($offset) === $value;
 }
Example #29
0
function dnpt($ext_ip, $ext_prefix, $int_prefix)
{
    $debug = false;
    // This is not a complete solution!!!!!!!!!!!!!!!!!!!!!!!!!!
    $ext_prefix = str_replace(":", "", $ext_prefix);
    $int_prefix = str_replace(":", "", $int_prefix);
    // hehe
    $sauce = hexdec(split(":", $ext_ip)[4]);
    $ext_c = icmpChecksum(hex2bin($ext_prefix));
    $int_c = icmpChecksum(hex2bin($int_prefix));
    if ($debug) {
        print_r(unpack('n', $int_c));
    }
    $diff = unpack('n', $ext_c)[1] - unpack('n', $int_c)[1];
    if ($diff < 0) {
        $diff = 0xffff + $diff;
    }
    $diff = $sauce - $diff;
    if ($debug) {
        print bin2hex($ext_c);
        print "\n";
        print bin2hex($int_c);
        print "\n";
        print dechex($diff);
        print "\n";
    }
    $out = split(":", $ext_ip);
    $out[4] = dechex($diff);
    $out = join($out, ":");
    return $out;
}
Example #30
-1
 /**
  *	Génère l'avatar
  */
 public function run()
 {
     //On créer l'image avec les dimentions données
     $image = imagecreate($this->_size, $this->_size);
     //On créer la couleur en fonction du hash de la chaine de caractères
     $color = imagecolorallocate($image, hexdec(substr($this->_color, 0, 2)), hexdec(substr($this->_color, 2, 2)), hexdec(substr($this->_color, 4, 2)));
     //on défini le fond de l'image (blanc)
     $bg = imagecolorallocate($image, 255, 255, 255);
     //nombre de blocs à placer dans l'image (taille de l'image/taille des blocs)
     $c = $this->_size / $this->_blockSize;
     for ($x = 0; $x < ceil($c / 2); $x++) {
         for ($y = 0; $y < $c; $y++) {
             // Si le nombre est pair $pixel vaut true sinon $pixel vaut false
             $pixel = hexdec($this->_hash[(int) ($x * ceil($c / 2)) + $y]) % 2 == 0;
             if ($pixel) {
                 $pixelColor = $color;
             } else {
                 $pixelColor = $bg;
             }
             // On place chaque bloc de l'image
             //imagefilledrectangle($image, $x*$this->_blockSize, $y*$this->_blockSize, ($x+1)*$this->_blockSize, ($y+1)*$this->_blockSize, $pixelColor);
             //imagefilledrectangle($image, $this->_size-$x*$this->_blockSize, $y*$this->_blockSize, $this->_size-($x+1)*$this->_blockSize, ($y+1)*$this->_blockSize, $pixelColor);
             imagefilledrectangle($image, $x * $this->_blockSize, $y * $this->_blockSize, ($x + 1) * $this->_blockSize, ($y + 1) * $this->_blockSize, $pixelColor);
             imagefilledrectangle($image, $this->_size - $x * $this->_blockSize, $y * $this->_blockSize, $this->_size - ($x + 1) * $this->_blockSize, ($y + 1) * $this->_blockSize, $pixelColor);
         }
     }
     ob_start();
     imagepng($image);
     //on place l'image en mémoire
     $this->_image = ob_get_contents();
     ob_clean();
 }