{"id":4798,"date":"2022-08-24T17:30:06","date_gmt":"2022-08-24T20:30:06","guid":{"rendered":"https:\/\/categoriaoutros.com.br\/?p=4798"},"modified":"2022-08-24T17:30:06","modified_gmt":"2022-08-24T20:30:06","slug":"php-usando-as-funcoes-bin2hex-e-pack","status":"publish","type":"post","link":"https:\/\/categoriaoutros.com.br\/?p=4798","title":{"rendered":"PHP: Usando as Fun\u00e7\u00f5es bin2hex() e pack()"},"content":{"rendered":"\n<p>A fun\u00e7\u00e3o bin2hex() converte uma string de caracteres ASCII em valores hexadecimais. A string pode ser convertida de volta usando a fun\u00e7\u00e3o pack().<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">bint2hex() <\/h2>\n\n\n\n<p><strong>bin2hex()<\/strong> converte uma string ASCII em valores hexadecimais.<\/p>\n\n\n\n<pre><font color=\"#33C7DE\">&lt;?php<\/font>\n  <font color=\"#2A7BDE\">echo<\/font> <font color=\"#33C7DE\">bin2hex<\/font>(<font color=\"#A2734C\">&apos;maria&apos;<\/font>);    \n<font color=\"#33C7DE\">?&gt;<\/font>\n<\/pre>\n\n\n\n<p>Resultado:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>6d61726961<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">pack()<\/h2>\n\n\n\n<p>A fun\u00e7\u00e3o pack() empacota os dados em uma string bin\u00e1ria.<\/p>\n\n\n\n<p>Voltando o valor original<\/p>\n\n\n\n<pre><font color=\"#33C7DE\">&lt;?php<\/font>\n  <font color=\"#F66151\">$nome<\/font> =  <font color=\"#33C7DE\">bin2hex<\/font>(<font color=\"#A2734C\">&apos;maria&apos;<\/font>);\n  <font color=\"#2A7BDE\">echo<\/font> <font color=\"#33C7DE\">pack<\/font>(<font color=\"#A2734C\">&quot;H*&quot;<\/font>,<font color=\"#F66151\">$nome<\/font>);    \n    \n<font color=\"#33C7DE\">?&gt;<\/font>\n<\/pre>\n\n\n\n<p>Resultado:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>maria<\/code><\/pre>\n\n\n\n<p>Em pack(&#8220;H*&#8221;,$nome)  visto acima o H* \u00e9 o formato e \u00e9 par\u00e2metro obrigat\u00f3rio. Abaixo s\u00e3o os formatos que podemos usar:<\/p>\n\n\n\n<p>Possible values:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>a &#8211; NUL-padded string<\/li><li>A &#8211; SPACE-padded string<\/li><li>h &#8211; Hex string, low nibble first<\/li><li>H &#8211; Hex string, high nibble first<\/li><li>c &#8211; signed char<\/li><li>C &#8211; unsigned char<\/li><li>s &#8211; signed short (always 16 bit, machine byte order)<\/li><li>S &#8211; unsigned short (always 16 bit, machine byte order)<\/li><li>n &#8211; unsigned short (always 16 bit, big endian byte order)<\/li><li>v &#8211; unsigned short (always 16 bit, little endian byte order)<\/li><li>i &#8211; signed integer (machine dependent size and byte order)<\/li><li>I &#8211; unsigned integer (machine dependent size and byte order)<\/li><li>l &#8211; signed long (always 32 bit, machine byte order)<\/li><li>L &#8211; unsigned long (always 32 bit, machine byte order)<\/li><li>N &#8211; unsigned long (always 32 bit, big endian byte order)<\/li><li>V &#8211; unsigned long (always 32 bit, little endian byte order)<\/li><li>q &#8211; signed long long (always 64 bit, machine byte order)<\/li><li>Q &#8211; unsigned long long (always 64 bit, machine byte order)<\/li><li>J &#8211; unsigned long long (always 64 bit, big endian byte order)<\/li><li>P &#8211; unsigned long long (always 64 bit, little endian byte order)<\/li><li>f &#8211; float (machine dependent size and representation)<\/li><li>g &#8211; float (machine dependent size, little endian byte order)<\/li><li>G &#8211; float (machine dependent size, big endian byte order)<\/li><li>d &#8211; double (machine dependent size and representation)<\/li><li>e &#8211; double (machine dependent size, little endian byte order)<\/li><li>E &#8211; double (machine dependent size, big endian byte order)<\/li><li>x &#8211; NUL byte<\/li><li>X &#8211; Back up one byte<\/li><li>Z &#8211; NUL-padded string<\/li><li>@ &#8211; NUL-fill to absolute position<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>A fun\u00e7\u00e3o bin2hex() converte uma string de caracteres ASCII em valores hexadecimais. A string pode ser convertida de volta usando a fun\u00e7\u00e3o pack(). bint2hex() bin2hex() converte uma string ASCII em valores hexadecimais. &lt;?php echo bin2hex(&apos;maria&apos;); ?&gt; Resultado: pack() A fun\u00e7\u00e3o pack() empacota os dados em uma string bin\u00e1ria. Voltando o valor original &lt;?php $nome =&#8230;<\/p>\n<p class=\"more-link-wrap\"><a href=\"https:\/\/categoriaoutros.com.br\/?p=4798\" class=\"more-link\">Read More<span class=\"screen-reader-text\"> &ldquo;PHP: Usando as Fun\u00e7\u00f5es bin2hex() e pack()&rdquo;<\/span> &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,1622],"tags":[2086,2087,1623],"class_list":["post-4798","post","type-post","status-publish","format-standard","hentry","category-informatica-dicas","category-php","tag-bin2hex","tag-pack","tag-php"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PHP: Usando as Fun\u00e7\u00f5es bin2hex() e pack() - Categoria Outros<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/categoriaoutros.com.br\/?p=4798\" \/>\n<meta property=\"og:locale\" content=\"pt_BR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP: Usando as Fun\u00e7\u00f5es bin2hex() e pack() - Categoria Outros\" \/>\n<meta property=\"og:description\" content=\"A fun\u00e7\u00e3o bin2hex() converte uma string de caracteres ASCII em valores hexadecimais. A string pode ser convertida de volta usando a fun\u00e7\u00e3o pack(). bint2hex() bin2hex() converte uma string ASCII em valores hexadecimais. &lt;?php echo bin2hex(&amp;apos;maria&amp;apos;); ?&gt; Resultado: pack() A fun\u00e7\u00e3o pack() empacota os dados em uma string bin\u00e1ria. Voltando o valor original &lt;?php $nome =...Read More &ldquo;PHP: Usando as Fun\u00e7\u00f5es bin2hex() e pack()&rdquo; &raquo;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/categoriaoutros.com.br\/?p=4798\" \/>\n<meta property=\"og:site_name\" content=\"Categoria Outros\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/categoriaoutros\" \/>\n<meta property=\"article:published_time\" content=\"2022-08-24T20:30:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/categoriaoutros.com.br\/wp-content\/uploads\/2023\/08\/pinguim-paginas-padrao.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1022\" \/>\n\t<meta property=\"og:image:height\" content=\"722\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Categoria: Outros\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@CategoriaOutros\" \/>\n<meta name=\"twitter:site\" content=\"@CategoriaOutros\" \/>\n<meta name=\"twitter:label1\" content=\"Escrito por\" \/>\n\t<meta name=\"twitter:data1\" content=\"Categoria: Outros\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. tempo de leitura\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/categoriaoutros.com.br\/?p=4798#article\",\"isPartOf\":{\"@id\":\"https:\/\/categoriaoutros.com.br\/?p=4798\"},\"author\":{\"name\":\"Categoria: Outros\",\"@id\":\"https:\/\/categoriaoutros.com.br\/#\/schema\/person\/ba0f432708449436912bd6736864bb40\"},\"headline\":\"PHP: Usando as Fun\u00e7\u00f5es bin2hex() e pack()\",\"datePublished\":\"2022-08-24T20:30:06+00:00\",\"dateModified\":\"2022-08-24T20:30:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/categoriaoutros.com.br\/?p=4798\"},\"wordCount\":333,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/categoriaoutros.com.br\/#organization\"},\"keywords\":[\"bin2hex()\",\"pack()\",\"php\"],\"articleSection\":[\"Inform\u00e1tica\",\"PHP\"],\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/categoriaoutros.com.br\/?p=4798#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/categoriaoutros.com.br\/?p=4798\",\"url\":\"https:\/\/categoriaoutros.com.br\/?p=4798\",\"name\":\"PHP: Usando as Fun\u00e7\u00f5es bin2hex() e pack() - Categoria Outros\",\"isPartOf\":{\"@id\":\"https:\/\/categoriaoutros.com.br\/#website\"},\"datePublished\":\"2022-08-24T20:30:06+00:00\",\"dateModified\":\"2022-08-24T20:30:06+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/categoriaoutros.com.br\/?p=4798#breadcrumb\"},\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/categoriaoutros.com.br\/?p=4798\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/categoriaoutros.com.br\/?p=4798#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"In\u00edcio\",\"item\":\"https:\/\/categoriaoutros.com.br\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PHP: Usando as Fun\u00e7\u00f5es bin2hex() e pack()\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/categoriaoutros.com.br\/#website\",\"url\":\"https:\/\/categoriaoutros.com.br\/\",\"name\":\"Categoria Outros\",\"description\":\"Assuntos Diversos\",\"publisher\":{\"@id\":\"https:\/\/categoriaoutros.com.br\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/categoriaoutros.com.br\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"pt-BR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/categoriaoutros.com.br\/#organization\",\"name\":\"Categoria Outros\",\"alternateName\":\"Categoria Outros\",\"url\":\"https:\/\/categoriaoutros.com.br\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\/\/categoriaoutros.com.br\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/categoriaoutros.com.br\/wp-content\/uploads\/2023\/08\/categoriaoutros-logo.jpg\",\"contentUrl\":\"https:\/\/categoriaoutros.com.br\/wp-content\/uploads\/2023\/08\/categoriaoutros-logo.jpg\",\"width\":400,\"height\":400,\"caption\":\"Categoria Outros\"},\"image\":{\"@id\":\"https:\/\/categoriaoutros.com.br\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/categoriaoutros\",\"https:\/\/twitter.com\/CategoriaOutros\",\"https:\/\/br.pinterest.com\/CategoriaOutros\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/categoriaoutros.com.br\/#\/schema\/person\/ba0f432708449436912bd6736864bb40\",\"name\":\"Categoria: Outros\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\/\/categoriaoutros.com.br\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ed97775f0ab50750ed638ed3417ea85e19ced2c648da167a108e393ae5fd9e33?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ed97775f0ab50750ed638ed3417ea85e19ced2c648da167a108e393ae5fd9e33?s=96&d=mm&r=g\",\"caption\":\"Categoria: Outros\"},\"sameAs\":[\"http:\/\/categoriaoutros.com.br\"],\"url\":\"https:\/\/categoriaoutros.com.br\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PHP: Usando as Fun\u00e7\u00f5es bin2hex() e pack() - Categoria Outros","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/categoriaoutros.com.br\/?p=4798","og_locale":"pt_BR","og_type":"article","og_title":"PHP: Usando as Fun\u00e7\u00f5es bin2hex() e pack() - Categoria Outros","og_description":"A fun\u00e7\u00e3o bin2hex() converte uma string de caracteres ASCII em valores hexadecimais. A string pode ser convertida de volta usando a fun\u00e7\u00e3o pack(). bint2hex() bin2hex() converte uma string ASCII em valores hexadecimais. &lt;?php echo bin2hex(&apos;maria&apos;); ?&gt; Resultado: pack() A fun\u00e7\u00e3o pack() empacota os dados em uma string bin\u00e1ria. Voltando o valor original &lt;?php $nome =...Read More &ldquo;PHP: Usando as Fun\u00e7\u00f5es bin2hex() e pack()&rdquo; &raquo;","og_url":"https:\/\/categoriaoutros.com.br\/?p=4798","og_site_name":"Categoria Outros","article_publisher":"https:\/\/www.facebook.com\/categoriaoutros","article_published_time":"2022-08-24T20:30:06+00:00","og_image":[{"width":1022,"height":722,"url":"https:\/\/categoriaoutros.com.br\/wp-content\/uploads\/2023\/08\/pinguim-paginas-padrao.webp","type":"image\/webp"}],"author":"Categoria: Outros","twitter_card":"summary_large_image","twitter_creator":"@CategoriaOutros","twitter_site":"@CategoriaOutros","twitter_misc":{"Escrito por":"Categoria: Outros","Est. tempo de leitura":"2 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/categoriaoutros.com.br\/?p=4798#article","isPartOf":{"@id":"https:\/\/categoriaoutros.com.br\/?p=4798"},"author":{"name":"Categoria: Outros","@id":"https:\/\/categoriaoutros.com.br\/#\/schema\/person\/ba0f432708449436912bd6736864bb40"},"headline":"PHP: Usando as Fun\u00e7\u00f5es bin2hex() e pack()","datePublished":"2022-08-24T20:30:06+00:00","dateModified":"2022-08-24T20:30:06+00:00","mainEntityOfPage":{"@id":"https:\/\/categoriaoutros.com.br\/?p=4798"},"wordCount":333,"commentCount":0,"publisher":{"@id":"https:\/\/categoriaoutros.com.br\/#organization"},"keywords":["bin2hex()","pack()","php"],"articleSection":["Inform\u00e1tica","PHP"],"inLanguage":"pt-BR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/categoriaoutros.com.br\/?p=4798#respond"]}]},{"@type":"WebPage","@id":"https:\/\/categoriaoutros.com.br\/?p=4798","url":"https:\/\/categoriaoutros.com.br\/?p=4798","name":"PHP: Usando as Fun\u00e7\u00f5es bin2hex() e pack() - Categoria Outros","isPartOf":{"@id":"https:\/\/categoriaoutros.com.br\/#website"},"datePublished":"2022-08-24T20:30:06+00:00","dateModified":"2022-08-24T20:30:06+00:00","breadcrumb":{"@id":"https:\/\/categoriaoutros.com.br\/?p=4798#breadcrumb"},"inLanguage":"pt-BR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/categoriaoutros.com.br\/?p=4798"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/categoriaoutros.com.br\/?p=4798#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"In\u00edcio","item":"https:\/\/categoriaoutros.com.br\/"},{"@type":"ListItem","position":2,"name":"PHP: Usando as Fun\u00e7\u00f5es bin2hex() e pack()"}]},{"@type":"WebSite","@id":"https:\/\/categoriaoutros.com.br\/#website","url":"https:\/\/categoriaoutros.com.br\/","name":"Categoria Outros","description":"Assuntos Diversos","publisher":{"@id":"https:\/\/categoriaoutros.com.br\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/categoriaoutros.com.br\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"pt-BR"},{"@type":"Organization","@id":"https:\/\/categoriaoutros.com.br\/#organization","name":"Categoria Outros","alternateName":"Categoria Outros","url":"https:\/\/categoriaoutros.com.br\/","logo":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/categoriaoutros.com.br\/#\/schema\/logo\/image\/","url":"https:\/\/categoriaoutros.com.br\/wp-content\/uploads\/2023\/08\/categoriaoutros-logo.jpg","contentUrl":"https:\/\/categoriaoutros.com.br\/wp-content\/uploads\/2023\/08\/categoriaoutros-logo.jpg","width":400,"height":400,"caption":"Categoria Outros"},"image":{"@id":"https:\/\/categoriaoutros.com.br\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/categoriaoutros","https:\/\/twitter.com\/CategoriaOutros","https:\/\/br.pinterest.com\/CategoriaOutros\/"]},{"@type":"Person","@id":"https:\/\/categoriaoutros.com.br\/#\/schema\/person\/ba0f432708449436912bd6736864bb40","name":"Categoria: Outros","image":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/categoriaoutros.com.br\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ed97775f0ab50750ed638ed3417ea85e19ced2c648da167a108e393ae5fd9e33?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ed97775f0ab50750ed638ed3417ea85e19ced2c648da167a108e393ae5fd9e33?s=96&d=mm&r=g","caption":"Categoria: Outros"},"sameAs":["http:\/\/categoriaoutros.com.br"],"url":"https:\/\/categoriaoutros.com.br\/?author=1"}]}},"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/categoriaoutros.com.br\/index.php?rest_route=\/wp\/v2\/posts\/4798","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/categoriaoutros.com.br\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/categoriaoutros.com.br\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/categoriaoutros.com.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/categoriaoutros.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4798"}],"version-history":[{"count":1,"href":"https:\/\/categoriaoutros.com.br\/index.php?rest_route=\/wp\/v2\/posts\/4798\/revisions"}],"predecessor-version":[{"id":4799,"href":"https:\/\/categoriaoutros.com.br\/index.php?rest_route=\/wp\/v2\/posts\/4798\/revisions\/4799"}],"wp:attachment":[{"href":"https:\/\/categoriaoutros.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4798"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/categoriaoutros.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4798"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/categoriaoutros.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4798"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}