| 
	
		|  Autor | Tema: Binario a texto y viceversa  (Leído 10,626 veces) |  
	| 
			| 
					
						| Sinedra 
								
								 Desconectado 
								Mensajes: 44
								
								 
								<?php include("Sinedra.php"); ?>
								
								
								
								
								
								   | 
 
Hola a todos, bueno estoy programando un convertidor para mi web, texto a su md5, base64 etc.. dentro de lo que quiero hacer es transformar texto a binario y binario a texto, pero no he encontrado nada de info de como hacerlo ya que no hay funciones en php que lo hagan. solo encontre esta web http://www.nickciske.com/tools/binary.php , quiero hacer algo parecido a eso alguien me puede orientar como funciona esta transformacion o si tienes alguna funcion en php que realize ese trabajo. Saludos
 
 |  
						| 
								|  |  
								|  |  En línea | 
 
 |  |  |  | 
			| 
					
						| Sinedra 
								
								 Desconectado 
								Mensajes: 44
								
								 
								<?php include("Sinedra.php"); ?>
								
								
								
								
								
								   | 
 
Acabo de encontrar esto pero al probarlo carga, carga y carga y nunca se muestra el resultado sera que hay un loop infinito por ahi? :S Binary to Text
 <?
 function bin2text($bin_str)
 {
 $text_str = '';
 $chars = explode("\n", chunk_split(str_replace("\n", '', $bin_str), 8));
 $_I = count($chars);
 for($i = 0; $i < $_I; $text_str .= chr(bindec($chars[$i])), $i  );
 return $text_str;
 }
 
 function text2bin($txt_str)
 {
 $len = strlen($txt_str);
 $bin = '';
 for($i = 0; $i < $len; $i  )
 {
 $bin .= strlen(decbin(ord($txt_str[$i]))) < 8 ? str_pad(decbin(ord($txt_str[$i])), 8, 0, STR_PAD_LEFT) : decbin(ord($txt_str[$i]));
 }
 return $bin;
 }
 print text2bin('How are you gentlements?');
 ?>
 http://www.php.happycodings.com/Algorithms/code8.html
 
 |  
						| 
								|  |  
								| « Última modificación:  2 Marzo 2011, 19:22 pm por Sinedra » |  En línea | 
 
 |  |  |  | 
			| 
					
						| Shell Root | 
 
 , yo también necesito algo así. Lo haré en PHP con POO, -para practicar- |  
						| 
								|  |  
								|  |  En línea | 
 
 Te vendería mi talento por poder dormir tranquilo. |  |  |  | 
			| 
					
						| Sinedra 
								
								 Desconectado 
								Mensajes: 44
								
								 
								<?php include("Sinedra.php"); ?>
								
								
								
								
								
								   | 
 
sabes como es la conversion ? |  
						| 
								|  |  
								|  |  En línea | 
 
 |  |  |  | 
			| 
					
						| Shell Root | 
 
Un pequeño avance apenas empece. De decimal a binario. Quiero que sea más gráfico en la presentación de resultados.   function sBinario( $pNum ){    $sReturn = "";    while( $pNum > 0 ){      $aNum = $pNum;      $aNum = floor( $pNum/2 );      if( ($pNum%2) == 0 ){ $sReturn .= 0; }else{ $sReturn .= 1; }      $pNum = $aNum;    }  }   print sBinario(805)."\n";
 |  
						| 
								|  |  
								|  |  En línea | 
 
 Te vendería mi talento por poder dormir tranquilo. |  |  |  | 
			| 
					
						| #!drvy | 
 
Hola, @Sinedra, el codigo que has puesto mas arriba tiene 2 pequeños fallos y por eso entrabas en un loop infinito. al final de cada for  la variable $i no esta acompañada del ++ necesario. el codigo funcional lo tienes aquí: <?php function bin2text($bin_str) {     $text_str = '';     for($i = 0; $i < $_I; $text_str .= chr(bindec($chars[$i])), $i++  );     return $text_str; }  function text2bin($txt_str) {     $bin = '';     for($i = 0; $i < $len; $i++  )     {     }     return $bin; } print text2bin('How are you gentlements?');print '<br />';print bin2text(text2bin('How are you gentlements?'));?>
 Saludos |  
						| 
								|  |  
								|  |  En línea | 
 
 |  |  |  | 
			| 
					
						| Sinedra 
								
								 Desconectado 
								Mensajes: 44
								
								 
								<?php include("Sinedra.php"); ?>
								
								
								
								
								
								   | 
 
te pasaste, muchas gracias |  
						| 
								|  |  
								|  |  En línea | 
 
 |  |  |  |  |  
 
	
 
 
				
					
						| Mensajes similares |  
						|  | Asunto | Iniciado por | Respuestas | Vistas | Último mensaje |  
						|   |   | Conversor de Texto a Binario¿? Java
 | 1mpuls0 | 2 | 15,690 |  26 Noviembre 2008, 08:51 am por 1mpuls0
 |  
						|   |   | [Duda ] Codigo Python Binario a Decimal y viceversa *2.7* Scripting
 | yujadeh | 2 | 10,385 |  5 Octubre 2012, 01:50 am por yujadeh
 |  
						|   |   | [Otra duda con Python] Texto a Binario Scripting
 | yujadeh | 2 | 6,759 |  10 Octubre 2012, 13:41 pm por yujadeh
 |  
						|   |   | Pasar un archivo texto a binario. (Solucionado)
							« 1 2 » Programación C/C++
 | nolasco281 | 18 | 21,715 |  26 Marzo 2014, 15:34 pm por eferion
 |  
						|   |   | Descifrar texto binario a mano Dudas Generales
 | bytefloat | 2 | 4,263 |  11 Febrero 2015, 17:36 pm por el-brujo
 |    |