Skip to content

Instantly share code, notes, and snippets.

@hutt
Last active March 17, 2024 22:29
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hutt/8978333 to your computer and use it in GitHub Desktop.
Save hutt/8978333 to your computer and use it in GitHub Desktop.
Convert string to binary / binary to string
<?php
/*******************************
*
* Convert Text to Binary ASCII
* oder so.
*
*******************************/
header("Content-Type: text/html; charset=utf-8");
function textBinASCII($text){
$bin = array();
for($i=0; strlen($text)>$i; $i++)
$bin[] = decbin(ord($text[$i]));
return implode(' ',$bin);
}
function ASCIIBinText($bin){
$text = array();
$bin = explode(" ", $bin);
for($i=0; count($bin)>$i; $i++)
$text[] = chr(bindec($bin[$i]));
return implode($text);
}
?>
@amirshnll
Copy link

very good.

@Minosuko
Copy link

Thank for code, I completed my secure Crypto PHP

@Santtiago
Copy link

Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment